﻿USE [CustomersSuppliers]


--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Addresses-Insert]    Script Date: [[20120914064947]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064947]]
-- Description:	Insert record into table [dbo].[Addresses]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Addresses-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Addresses-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Addresses-Insert]
	/*@Address_RowNumber int =Null OUTPUT , 
	@Address_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Address_Code varchar(50) =Null  , 
	@Country_ID uniqueidentifier =Null  , 
	@State_NameAr varchar(50) =Null  , 
	@State_NameEn varchar(50) =Null  , 
	@Town_NameAr varchar(50) =Null  , 
	@Town_NameEn varchar(50) =Null  , 
	@Address_NameAr varchar(50) =Null  , 
	@Address_NameEn varchar(50) =Null  , 
	@Postal_Code varchar(50) =Null  , 
	@Address_Notes varchar(max) =Null  , 
	@Address_Search varchar(max) =Null  , 
	@Address_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Addresses](/*[Address_ID], [Dealer_ID], [Address_Code], [Country_ID], [State_NameAr], [State_NameEn], [Town_NameAr], [Town_NameEn], [Address_NameAr], [Address_NameEn], [Postal_Code], [Address_Notes], [Address_Search]*/)
	VALUES     (/*@Address_ID, @Dealer_ID, @Address_Code, @Country_ID, @State_NameAr, @State_NameEn, @Town_NameAr, @Town_NameEn, @Address_NameAr, @Address_NameEn, @Postal_Code, @Address_Notes, @Address_Search*/)

	/*SELECT @Address_RowNumber = [Address_RowNumber], @Address_TimeStamp = [Address_TimeStamp]
    FROM [dbo].[Addresses]
    WHERE  ( [Address_ID] =@Address_ID )
	AND  ( [Dealer_ID] =@Dealer_ID )
	AND  ( [Address_Code] =@Address_Code )
	AND  ( [Country_ID] =@Country_ID )
	AND  ( [State_NameAr] =@State_NameAr )
	AND  ( [State_NameEn] =@State_NameEn )
	AND  ( [Town_NameAr] =@Town_NameAr )
	AND  ( [Town_NameEn] =@Town_NameEn )
	AND  ( [Address_NameAr] =@Address_NameAr )
	AND  ( [Address_NameEn] =@Address_NameEn )
	AND  ( [Postal_Code] =@Postal_Code )
	AND  ( [Address_Notes] =@Address_Notes )
	AND  ( [Address_Search] =@Address_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Addresses-update]    Script Date: [[20120914064947]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064947]]
-- Description:	Update record in table [dbo].[Addresses]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Addresses-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Addresses-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Addresses-update]
	/*@Address_RowNumber int =Null OUTPUT , 
	@Address_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Address_Code varchar(50) =Null  , 
	@Country_ID uniqueidentifier =Null  , 
	@State_NameAr varchar(50) =Null  , 
	@State_NameEn varchar(50) =Null  , 
	@Town_NameAr varchar(50) =Null  , 
	@Town_NameEn varchar(50) =Null  , 
	@Address_NameAr varchar(50) =Null  , 
	@Address_NameEn varchar(50) =Null  , 
	@Postal_Code varchar(50) =Null  , 
	@Address_Notes varchar(max) =Null  , 
	@Address_Search varchar(max) =Null  , 
	@Address_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Address_TimeStamp]
    FROM [dbo].[Addresses]
    	WHERE ([Address_ID] = @Address_ID)

    IF  @OldTimeStamp = @Address_TimeStamp
    BEGIN*/
		Update [dbo].[Addresses] SET 
		/*[Address_ID] =@Address_ID, 
		[Dealer_ID] =@Dealer_ID, 
		[Address_Code] =@Address_Code, 
		[Country_ID] =@Country_ID, 
		[State_NameAr] =@State_NameAr, 
		[State_NameEn] =@State_NameEn, 
		[Town_NameAr] =@Town_NameAr, 
		[Town_NameEn] =@Town_NameEn, 
		[Address_NameAr] =@Address_NameAr, 
		[Address_NameEn] =@Address_NameEn, 
		[Postal_Code] =@Postal_Code, 
		[Address_Notes] =@Address_Notes, 
		[Address_Search] =@Address_Search*/
		/*WHERE ([Address_ID] = @Address_ID)*/
	/*END*/

	/*SELECT @Address_RowNumber = [Address_RowNumber], @Address_TimeStamp = [Address_TimeStamp]
    FROM [dbo].[Addresses]
	WHERE ([Address_ID] = @Address_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Addresses-Insert-Update]    Script Date: [[20120914064947]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064947]]
-- Description:	Insert OR Update record into table [dbo].[Addresses]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Addresses-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Addresses-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Addresses-Insert-Update]
	/*@Address_RowNumber int =Null OUTPUT , 
	@Address_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Address_Code varchar(50) =Null  , 
	@Country_ID uniqueidentifier =Null  , 
	@State_NameAr varchar(50) =Null  , 
	@State_NameEn varchar(50) =Null  , 
	@Town_NameAr varchar(50) =Null  , 
	@Town_NameEn varchar(50) =Null  , 
	@Address_NameAr varchar(50) =Null  , 
	@Address_NameEn varchar(50) =Null  , 
	@Postal_Code varchar(50) =Null  , 
	@Address_Notes varchar(max) =Null  , 
	@Address_Search varchar(max) =Null  , 
	@Address_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Addresses] 
					/*WHERE ([Address_ID] = @Address_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Addresses](/*[Address_ID], [Dealer_ID], [Address_Code], [Country_ID], [State_NameAr], [State_NameEn], [Town_NameAr], [Town_NameEn], [Address_NameAr], [Address_NameEn], [Postal_Code], [Address_Notes], [Address_Search]*/)
		VALUES     (/*@Address_ID, @Dealer_ID, @Address_Code, @Country_ID, @State_NameAr, @State_NameEn, @Town_NameAr, @Town_NameEn, @Address_NameAr, @Address_NameEn, @Postal_Code, @Address_Notes, @Address_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Address_TimeStamp]
		FROM [dbo].[Addresses]
    	WHERE ([Address_ID] = @Address_ID)

		IF  @OldTimeStamp = @Address_TimeStamp
		BEGIN*/
			Update [dbo].[Addresses] SET 
			/*[Address_ID] =@Address_ID, 
			[Dealer_ID] =@Dealer_ID, 
			[Address_Code] =@Address_Code, 
			[Country_ID] =@Country_ID, 
			[State_NameAr] =@State_NameAr, 
			[State_NameEn] =@State_NameEn, 
			[Town_NameAr] =@Town_NameAr, 
			[Town_NameEn] =@Town_NameEn, 
			[Address_NameAr] =@Address_NameAr, 
			[Address_NameEn] =@Address_NameEn, 
			[Postal_Code] =@Postal_Code, 
			[Address_Notes] =@Address_Notes, 
			[Address_Search] =@Address_Search*/
			/*WHERE ([Address_ID] = @Address_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Address_RowNumber = [Address_RowNumber], @Address_TimeStamp = [Address_TimeStamp]
    FROM [dbo].[Addresses]
	WHERE ([Address_ID] = @Address_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Addresses-Delete]    Script Date: [[20120914064947]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064947]]
-- Description:	delete records from table [dbo].[Addresses] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Addresses-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Addresses-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Addresses-Delete]
	/*@Address_RowNumber int =null  , 
	@Address_ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Address_Code varchar(50) =null  , 
	@Country_ID uniqueidentifier =null  , 
	@State_NameAr varchar(50) =null  , 
	@State_NameEn varchar(50) =null  , 
	@Town_NameAr varchar(50) =null  , 
	@Town_NameEn varchar(50) =null  , 
	@Address_NameAr varchar(50) =null  , 
	@Address_NameEn varchar(50) =null  , 
	@Postal_Code varchar(50) =null  , 
	@Address_Notes varchar(max) =null  , 
	@Address_Search varchar(max) =null  , 
	@Address_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Addresses]
	WHERE /*( [Address_RowNumber] = ISNULL(@Address_RowNumber, [Address_RowNumber]) )
	AND ( [Address_ID] = ISNULL(@Address_ID, [Address_ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Address_Code] like ISNULL(@Address_Code, [Address_Code]) )
	AND ( [Country_ID] = ISNULL(@Country_ID, [Country_ID]) )
	AND ( [State_NameAr] like ISNULL(@State_NameAr, [State_NameAr]) )
	AND ( [State_NameEn] like ISNULL(@State_NameEn, [State_NameEn]) )
	AND ( [Town_NameAr] like ISNULL(@Town_NameAr, [Town_NameAr]) )
	AND ( [Town_NameEn] like ISNULL(@Town_NameEn, [Town_NameEn]) )
	AND ( [Address_NameAr] like ISNULL(@Address_NameAr, [Address_NameAr]) )
	AND ( [Address_NameEn] like ISNULL(@Address_NameEn, [Address_NameEn]) )
	AND ( [Postal_Code] like ISNULL(@Postal_Code, [Postal_Code]) )
	AND ( [Address_Notes] like ISNULL(@Address_Notes, [Address_Notes]) )
	AND ( [Address_Search] like ISNULL(@Address_Search, [Address_Search]) )
	AND ( [Address_TimeStamp] = ISNULL(@Address_TimeStamp, [Address_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Addresses-Select]    Script Date: [[20120914064947]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064947]]
-- Description:	select records from table [dbo].[Addresses] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Addresses-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Addresses-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Addresses-Select]
	/*@Address_RowNumber int =null  , 
	@Address_ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Address_Code varchar(50) =null  , 
	@Country_ID uniqueidentifier =null  , 
	@State_NameAr varchar(50) =null  , 
	@State_NameEn varchar(50) =null  , 
	@Town_NameAr varchar(50) =null  , 
	@Town_NameEn varchar(50) =null  , 
	@Address_NameAr varchar(50) =null  , 
	@Address_NameEn varchar(50) =null  , 
	@Postal_Code varchar(50) =null  , 
	@Address_Notes varchar(max) =null  , 
	@Address_Search varchar(max) =null  , 
	@Address_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Addresses]
	WHERE /*( [Address_RowNumber] = ISNULL(@Address_RowNumber, [Address_RowNumber]) )
	AND ( [Address_ID] = ISNULL(@Address_ID, [Address_ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Address_Code] like ISNULL(@Address_Code, [Address_Code]) )
	AND ( [Country_ID] = ISNULL(@Country_ID, [Country_ID]) )
	AND ( [State_NameAr] like ISNULL(@State_NameAr, [State_NameAr]) )
	AND ( [State_NameEn] like ISNULL(@State_NameEn, [State_NameEn]) )
	AND ( [Town_NameAr] like ISNULL(@Town_NameAr, [Town_NameAr]) )
	AND ( [Town_NameEn] like ISNULL(@Town_NameEn, [Town_NameEn]) )
	AND ( [Address_NameAr] like ISNULL(@Address_NameAr, [Address_NameAr]) )
	AND ( [Address_NameEn] like ISNULL(@Address_NameEn, [Address_NameEn]) )
	AND ( [Postal_Code] like ISNULL(@Postal_Code, [Postal_Code]) )
	AND ( [Address_Notes] like ISNULL(@Address_Notes, [Address_Notes]) )
	AND ( [Address_Search] like ISNULL(@Address_Search, [Address_Search]) )
	AND ( [Address_TimeStamp] = ISNULL(@Address_TimeStamp, [Address_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Banks-Insert]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Insert record into table [dbo].[Banks]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Banks-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Banks-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Banks-Insert]
	/*@Bank_RowNumber int =Null OUTPUT , 
	@Bank_ID uniqueidentifier =Null  , 
	@Bank_ParentID uniqueidentifier =Null  , 
	@Bank_Code varchar(50) =Null  , 
	@Bank_NameAr varchar(300) =Null  , 
	@Bank_NameEn varchar(300) =Null  , 
	@Bank_Notes varchar(max) =Null  , 
	@Bank_Search varchar(max) =Null  , 
	@Bank_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Banks](/*[Bank_ID], [Bank_ParentID], [Bank_Code], [Bank_NameAr], [Bank_NameEn], [Bank_Notes], [Bank_Search]*/)
	VALUES     (/*@Bank_ID, @Bank_ParentID, @Bank_Code, @Bank_NameAr, @Bank_NameEn, @Bank_Notes, @Bank_Search*/)

	/*SELECT @Bank_RowNumber = [Bank_RowNumber], @Bank_TimeStamp = [Bank_TimeStamp]
    FROM [dbo].[Banks]
    WHERE  ( [Bank_ID] =@Bank_ID )
	AND  ( [Bank_ParentID] =@Bank_ParentID )
	AND  ( [Bank_Code] =@Bank_Code )
	AND  ( [Bank_NameAr] =@Bank_NameAr )
	AND  ( [Bank_NameEn] =@Bank_NameEn )
	AND  ( [Bank_Notes] =@Bank_Notes )
	AND  ( [Bank_Search] =@Bank_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Banks-update]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Update record in table [dbo].[Banks]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Banks-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Banks-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Banks-update]
	/*@Bank_RowNumber int =Null OUTPUT , 
	@Bank_ID uniqueidentifier =Null  , 
	@Bank_ParentID uniqueidentifier =Null  , 
	@Bank_Code varchar(50) =Null  , 
	@Bank_NameAr varchar(300) =Null  , 
	@Bank_NameEn varchar(300) =Null  , 
	@Bank_Notes varchar(max) =Null  , 
	@Bank_Search varchar(max) =Null  , 
	@Bank_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Bank_TimeStamp]
    FROM [dbo].[Banks]
    	WHERE ([Bank_ID] = @Bank_ID)

    IF  @OldTimeStamp = @Bank_TimeStamp
    BEGIN*/
		Update [dbo].[Banks] SET 
		/*[Bank_ID] =@Bank_ID, 
		[Bank_ParentID] =@Bank_ParentID, 
		[Bank_Code] =@Bank_Code, 
		[Bank_NameAr] =@Bank_NameAr, 
		[Bank_NameEn] =@Bank_NameEn, 
		[Bank_Notes] =@Bank_Notes, 
		[Bank_Search] =@Bank_Search*/
		/*WHERE ([Bank_ID] = @Bank_ID)*/
	/*END*/

	/*SELECT @Bank_RowNumber = [Bank_RowNumber], @Bank_TimeStamp = [Bank_TimeStamp]
    FROM [dbo].[Banks]
	WHERE ([Bank_ID] = @Bank_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Banks-Insert-Update]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Insert OR Update record into table [dbo].[Banks]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Banks-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Banks-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Banks-Insert-Update]
	/*@Bank_RowNumber int =Null OUTPUT , 
	@Bank_ID uniqueidentifier =Null  , 
	@Bank_ParentID uniqueidentifier =Null  , 
	@Bank_Code varchar(50) =Null  , 
	@Bank_NameAr varchar(300) =Null  , 
	@Bank_NameEn varchar(300) =Null  , 
	@Bank_Notes varchar(max) =Null  , 
	@Bank_Search varchar(max) =Null  , 
	@Bank_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Banks] 
					/*WHERE ([Bank_ID] = @Bank_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Banks](/*[Bank_ID], [Bank_ParentID], [Bank_Code], [Bank_NameAr], [Bank_NameEn], [Bank_Notes], [Bank_Search]*/)
		VALUES     (/*@Bank_ID, @Bank_ParentID, @Bank_Code, @Bank_NameAr, @Bank_NameEn, @Bank_Notes, @Bank_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Bank_TimeStamp]
		FROM [dbo].[Banks]
    	WHERE ([Bank_ID] = @Bank_ID)

		IF  @OldTimeStamp = @Bank_TimeStamp
		BEGIN*/
			Update [dbo].[Banks] SET 
			/*[Bank_ID] =@Bank_ID, 
			[Bank_ParentID] =@Bank_ParentID, 
			[Bank_Code] =@Bank_Code, 
			[Bank_NameAr] =@Bank_NameAr, 
			[Bank_NameEn] =@Bank_NameEn, 
			[Bank_Notes] =@Bank_Notes, 
			[Bank_Search] =@Bank_Search*/
			/*WHERE ([Bank_ID] = @Bank_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Bank_RowNumber = [Bank_RowNumber], @Bank_TimeStamp = [Bank_TimeStamp]
    FROM [dbo].[Banks]
	WHERE ([Bank_ID] = @Bank_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Banks-Delete]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	delete records from table [dbo].[Banks] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Banks-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Banks-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Banks-Delete]
	/*@Bank_RowNumber int =null  , 
	@Bank_ID uniqueidentifier =null  , 
	@Bank_ParentID uniqueidentifier =null  , 
	@Bank_Code varchar(50) =null  , 
	@Bank_NameAr varchar(300) =null  , 
	@Bank_NameEn varchar(300) =null  , 
	@Bank_Notes varchar(max) =null  , 
	@Bank_Search varchar(max) =null  , 
	@Bank_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Banks]
	WHERE /*( [Bank_RowNumber] = ISNULL(@Bank_RowNumber, [Bank_RowNumber]) )
	AND ( [Bank_ID] = ISNULL(@Bank_ID, [Bank_ID]) )
	AND ( [Bank_ParentID] = ISNULL(@Bank_ParentID, [Bank_ParentID]) )
	AND ( [Bank_Code] like ISNULL(@Bank_Code, [Bank_Code]) )
	AND ( [Bank_NameAr] like ISNULL(@Bank_NameAr, [Bank_NameAr]) )
	AND ( [Bank_NameEn] like ISNULL(@Bank_NameEn, [Bank_NameEn]) )
	AND ( [Bank_Notes] like ISNULL(@Bank_Notes, [Bank_Notes]) )
	AND ( [Bank_Search] like ISNULL(@Bank_Search, [Bank_Search]) )
	AND ( [Bank_TimeStamp] = ISNULL(@Bank_TimeStamp, [Bank_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Banks-Select]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	select records from table [dbo].[Banks] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Banks-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Banks-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Banks-Select]
	/*@Bank_RowNumber int =null  , 
	@Bank_ID uniqueidentifier =null  , 
	@Bank_ParentID uniqueidentifier =null  , 
	@Bank_Code varchar(50) =null  , 
	@Bank_NameAr varchar(300) =null  , 
	@Bank_NameEn varchar(300) =null  , 
	@Bank_Notes varchar(max) =null  , 
	@Bank_Search varchar(max) =null  , 
	@Bank_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Banks]
	WHERE /*( [Bank_RowNumber] = ISNULL(@Bank_RowNumber, [Bank_RowNumber]) )
	AND ( [Bank_ID] = ISNULL(@Bank_ID, [Bank_ID]) )
	AND ( [Bank_ParentID] = ISNULL(@Bank_ParentID, [Bank_ParentID]) )
	AND ( [Bank_Code] like ISNULL(@Bank_Code, [Bank_Code]) )
	AND ( [Bank_NameAr] like ISNULL(@Bank_NameAr, [Bank_NameAr]) )
	AND ( [Bank_NameEn] like ISNULL(@Bank_NameEn, [Bank_NameEn]) )
	AND ( [Bank_Notes] like ISNULL(@Bank_Notes, [Bank_Notes]) )
	AND ( [Bank_Search] like ISNULL(@Bank_Search, [Bank_Search]) )
	AND ( [Bank_TimeStamp] = ISNULL(@Bank_TimeStamp, [Bank_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Insert]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Insert record into table [dbo].[Configrations]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Insert]
	/*@Configuration_RowNumber int =Null OUTPUT , 
	@Configuration_ID uniqueidentifier =Null  , 
	@Configuration_Name varchar(300) =Null  , 
	@Configuration_Value varchar(300) =Null  , 
	@Configuration_Notes varchar(max) =Null  , 
	@Configuration_Search varchar(max) =Null  , 
	@Configration_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Configrations](/*[Configuration_ID], [Configuration_Name], [Configuration_Value], [Configuration_Notes], [Configuration_Search]*/)
	VALUES     (/*@Configuration_ID, @Configuration_Name, @Configuration_Value, @Configuration_Notes, @Configuration_Search*/)

	/*SELECT @Configuration_RowNumber = [Configuration_RowNumber], @Configration_TimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
    WHERE  ( [Configuration_ID] =@Configuration_ID )
	AND  ( [Configuration_Name] =@Configuration_Name )
	AND  ( [Configuration_Value] =@Configuration_Value )
	AND  ( [Configuration_Notes] =@Configuration_Notes )
	AND  ( [Configuration_Search] =@Configuration_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-update]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Update record in table [dbo].[Configrations]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-update]
	/*@Configuration_RowNumber int =Null OUTPUT , 
	@Configuration_ID uniqueidentifier =Null  , 
	@Configuration_Name varchar(300) =Null  , 
	@Configuration_Value varchar(300) =Null  , 
	@Configuration_Notes varchar(max) =Null  , 
	@Configuration_Search varchar(max) =Null  , 
	@Configration_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
    	WHERE ([Configuration_ID] = @Configuration_ID)

    IF  @OldTimeStamp = @Configration_TimeStamp
    BEGIN*/
		Update [dbo].[Configrations] SET 
		/*[Configuration_ID] =@Configuration_ID, 
		[Configuration_Name] =@Configuration_Name, 
		[Configuration_Value] =@Configuration_Value, 
		[Configuration_Notes] =@Configuration_Notes, 
		[Configuration_Search] =@Configuration_Search*/
		/*WHERE ([Configuration_ID] = @Configuration_ID)*/
	/*END*/

	/*SELECT @Configuration_RowNumber = [Configuration_RowNumber], @Configration_TimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
	WHERE ([Configuration_ID] = @Configuration_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Insert-Update]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	Insert OR Update record into table [dbo].[Configrations]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Insert-Update]
	/*@Configuration_RowNumber int =Null OUTPUT , 
	@Configuration_ID uniqueidentifier =Null  , 
	@Configuration_Name varchar(300) =Null  , 
	@Configuration_Value varchar(300) =Null  , 
	@Configuration_Notes varchar(max) =Null  , 
	@Configuration_Search varchar(max) =Null  , 
	@Configration_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Configrations] 
					/*WHERE ([Configuration_ID] = @Configuration_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Configrations](/*[Configuration_ID], [Configuration_Name], [Configuration_Value], [Configuration_Notes], [Configuration_Search]*/)
		VALUES     (/*@Configuration_ID, @Configuration_Name, @Configuration_Value, @Configuration_Notes, @Configuration_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Configration_TimeStamp]
		FROM [dbo].[Configrations]
    	WHERE ([Configuration_ID] = @Configuration_ID)

		IF  @OldTimeStamp = @Configration_TimeStamp
		BEGIN*/
			Update [dbo].[Configrations] SET 
			/*[Configuration_ID] =@Configuration_ID, 
			[Configuration_Name] =@Configuration_Name, 
			[Configuration_Value] =@Configuration_Value, 
			[Configuration_Notes] =@Configuration_Notes, 
			[Configuration_Search] =@Configuration_Search*/
			/*WHERE ([Configuration_ID] = @Configuration_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Configuration_RowNumber = [Configuration_RowNumber], @Configration_TimeStamp = [Configration_TimeStamp]
    FROM [dbo].[Configrations]
	WHERE ([Configuration_ID] = @Configuration_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Delete]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	delete records from table [dbo].[Configrations] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Delete]
	/*@Configuration_RowNumber int =null  , 
	@Configuration_ID uniqueidentifier =null  , 
	@Configuration_Name varchar(300) =null  , 
	@Configuration_Value varchar(300) =null  , 
	@Configuration_Notes varchar(max) =null  , 
	@Configuration_Search varchar(max) =null  , 
	@Configration_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Configrations]
	WHERE /*( [Configuration_RowNumber] = ISNULL(@Configuration_RowNumber, [Configuration_RowNumber]) )
	AND ( [Configuration_ID] = ISNULL(@Configuration_ID, [Configuration_ID]) )
	AND ( [Configuration_Name] like ISNULL(@Configuration_Name, [Configuration_Name]) )
	AND ( [Configuration_Value] like ISNULL(@Configuration_Value, [Configuration_Value]) )
	AND ( [Configuration_Notes] like ISNULL(@Configuration_Notes, [Configuration_Notes]) )
	AND ( [Configuration_Search] like ISNULL(@Configuration_Search, [Configuration_Search]) )
	AND ( [Configration_TimeStamp] = ISNULL(@Configration_TimeStamp, [Configration_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Configrations-Select]    Script Date: [[20120914064948]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064948]]
-- Description:	select records from table [dbo].[Configrations] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Configrations-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Configrations-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Configrations-Select]
	/*@Configuration_RowNumber int =null  , 
	@Configuration_ID uniqueidentifier =null  , 
	@Configuration_Name varchar(300) =null  , 
	@Configuration_Value varchar(300) =null  , 
	@Configuration_Notes varchar(max) =null  , 
	@Configuration_Search varchar(max) =null  , 
	@Configration_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Configrations]
	WHERE /*( [Configuration_RowNumber] = ISNULL(@Configuration_RowNumber, [Configuration_RowNumber]) )
	AND ( [Configuration_ID] = ISNULL(@Configuration_ID, [Configuration_ID]) )
	AND ( [Configuration_Name] like ISNULL(@Configuration_Name, [Configuration_Name]) )
	AND ( [Configuration_Value] like ISNULL(@Configuration_Value, [Configuration_Value]) )
	AND ( [Configuration_Notes] like ISNULL(@Configuration_Notes, [Configuration_Notes]) )
	AND ( [Configuration_Search] like ISNULL(@Configuration_Search, [Configuration_Search]) )
	AND ( [Configration_TimeStamp] = ISNULL(@Configration_TimeStamp, [Configration_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Contacts-Insert]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	Insert record into table [dbo].[Contacts]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Contacts-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Contacts-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Contacts-Insert]
	/*@Contact_RowNumber int =Null OUTPUT , 
	@Contact_ID uniqueidentifier =Null  , 
	@Person_ID uniqueidentifier =Null  , 
	@ContactType_ID uniqueidentifier =Null  , 
	@Contact_Value varchar(max) =Null  , 
	@Contacts_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Contacts](/*[Contact_ID], [Person_ID], [ContactType_ID], [Contact_Value]*/)
	VALUES     (/*@Contact_ID, @Person_ID, @ContactType_ID, @Contact_Value*/)

	/*SELECT @Contact_RowNumber = [Contact_RowNumber], @Contacts_TimeStamp = [Contacts_TimeStamp]
    FROM [dbo].[Contacts]
    WHERE  ( [Contact_ID] =@Contact_ID )
	AND  ( [Person_ID] =@Person_ID )
	AND  ( [ContactType_ID] =@ContactType_ID )
	AND  ( [Contact_Value] =@Contact_Value )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Contacts-update]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	Update record in table [dbo].[Contacts]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Contacts-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Contacts-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Contacts-update]
	/*@Contact_RowNumber int =Null OUTPUT , 
	@Contact_ID uniqueidentifier =Null  , 
	@Person_ID uniqueidentifier =Null  , 
	@ContactType_ID uniqueidentifier =Null  , 
	@Contact_Value varchar(max) =Null  , 
	@Contacts_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Contacts_TimeStamp]
    FROM [dbo].[Contacts]
    	WHERE ([Contact_ID] = @Contact_ID)

    IF  @OldTimeStamp = @Contacts_TimeStamp
    BEGIN*/
		Update [dbo].[Contacts] SET 
		/*[Contact_ID] =@Contact_ID, 
		[Person_ID] =@Person_ID, 
		[ContactType_ID] =@ContactType_ID, 
		[Contact_Value] =@Contact_Value*/
		/*WHERE ([Contact_ID] = @Contact_ID)*/
	/*END*/

	/*SELECT @Contact_RowNumber = [Contact_RowNumber], @Contacts_TimeStamp = [Contacts_TimeStamp]
    FROM [dbo].[Contacts]
	WHERE ([Contact_ID] = @Contact_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Contacts-Insert-Update]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	Insert OR Update record into table [dbo].[Contacts]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Contacts-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Contacts-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Contacts-Insert-Update]
	/*@Contact_RowNumber int =Null OUTPUT , 
	@Contact_ID uniqueidentifier =Null  , 
	@Person_ID uniqueidentifier =Null  , 
	@ContactType_ID uniqueidentifier =Null  , 
	@Contact_Value varchar(max) =Null  , 
	@Contacts_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Contacts] 
					/*WHERE ([Contact_ID] = @Contact_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Contacts](/*[Contact_ID], [Person_ID], [ContactType_ID], [Contact_Value]*/)
		VALUES     (/*@Contact_ID, @Person_ID, @ContactType_ID, @Contact_Value*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Contacts_TimeStamp]
		FROM [dbo].[Contacts]
    	WHERE ([Contact_ID] = @Contact_ID)

		IF  @OldTimeStamp = @Contacts_TimeStamp
		BEGIN*/
			Update [dbo].[Contacts] SET 
			/*[Contact_ID] =@Contact_ID, 
			[Person_ID] =@Person_ID, 
			[ContactType_ID] =@ContactType_ID, 
			[Contact_Value] =@Contact_Value*/
			/*WHERE ([Contact_ID] = @Contact_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Contact_RowNumber = [Contact_RowNumber], @Contacts_TimeStamp = [Contacts_TimeStamp]
    FROM [dbo].[Contacts]
	WHERE ([Contact_ID] = @Contact_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Contacts-Delete]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	delete records from table [dbo].[Contacts] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Contacts-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Contacts-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Contacts-Delete]
	/*@Contact_RowNumber int =null  , 
	@Contact_ID uniqueidentifier =null  , 
	@Person_ID uniqueidentifier =null  , 
	@ContactType_ID uniqueidentifier =null  , 
	@Contact_Value varchar(max) =null  , 
	@Contacts_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Contacts]
	WHERE /*( [Contact_RowNumber] = ISNULL(@Contact_RowNumber, [Contact_RowNumber]) )
	AND ( [Contact_ID] = ISNULL(@Contact_ID, [Contact_ID]) )
	AND ( [Person_ID] = ISNULL(@Person_ID, [Person_ID]) )
	AND ( [ContactType_ID] = ISNULL(@ContactType_ID, [ContactType_ID]) )
	AND ( [Contact_Value] like ISNULL(@Contact_Value, [Contact_Value]) )
	AND ( [Contacts_TimeStamp] = ISNULL(@Contacts_TimeStamp, [Contacts_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Contacts-Select]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	select records from table [dbo].[Contacts] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Contacts-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Contacts-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Contacts-Select]
	/*@Contact_RowNumber int =null  , 
	@Contact_ID uniqueidentifier =null  , 
	@Person_ID uniqueidentifier =null  , 
	@ContactType_ID uniqueidentifier =null  , 
	@Contact_Value varchar(max) =null  , 
	@Contacts_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Contacts]
	WHERE /*( [Contact_RowNumber] = ISNULL(@Contact_RowNumber, [Contact_RowNumber]) )
	AND ( [Contact_ID] = ISNULL(@Contact_ID, [Contact_ID]) )
	AND ( [Person_ID] = ISNULL(@Person_ID, [Person_ID]) )
	AND ( [ContactType_ID] = ISNULL(@ContactType_ID, [ContactType_ID]) )
	AND ( [Contact_Value] like ISNULL(@Contact_Value, [Contact_Value]) )
	AND ( [Contacts_TimeStamp] = ISNULL(@Contacts_TimeStamp, [Contacts_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ContactTypes-Insert]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	Insert record into table [dbo].[ContactTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ContactTypes-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ContactTypes-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ContactTypes-Insert]
	/*@ContactType_RowNumber int =Null OUTPUT , 
	@ContactType_ID uniqueidentifier =Null  , 
	@ContactType_Code varchar(50) =Null  , 
	@ContactType_NameAr varchar(300) =Null  , 
	@ContactType_NameEn varchar(300) =Null  , 
	@ContactType_Notes varchar(max) =Null  , 
	@ContactType_Search varchar(max) =Null  , 
	@ContactType_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[ContactTypes](/*[ContactType_ID], [ContactType_Code], [ContactType_NameAr], [ContactType_NameEn], [ContactType_Notes], [ContactType_Search]*/)
	VALUES     (/*@ContactType_ID, @ContactType_Code, @ContactType_NameAr, @ContactType_NameEn, @ContactType_Notes, @ContactType_Search*/)

	/*SELECT @ContactType_RowNumber = [ContactType_RowNumber], @ContactType_TimeStamp = [ContactType_TimeStamp]
    FROM [dbo].[ContactTypes]
    WHERE  ( [ContactType_ID] =@ContactType_ID )
	AND  ( [ContactType_Code] =@ContactType_Code )
	AND  ( [ContactType_NameAr] =@ContactType_NameAr )
	AND  ( [ContactType_NameEn] =@ContactType_NameEn )
	AND  ( [ContactType_Notes] =@ContactType_Notes )
	AND  ( [ContactType_Search] =@ContactType_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ContactTypes-update]    Script Date: [[20120914064949]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064949]]
-- Description:	Update record in table [dbo].[ContactTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ContactTypes-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ContactTypes-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ContactTypes-update]
	/*@ContactType_RowNumber int =Null OUTPUT , 
	@ContactType_ID uniqueidentifier =Null  , 
	@ContactType_Code varchar(50) =Null  , 
	@ContactType_NameAr varchar(300) =Null  , 
	@ContactType_NameEn varchar(300) =Null  , 
	@ContactType_Notes varchar(max) =Null  , 
	@ContactType_Search varchar(max) =Null  , 
	@ContactType_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [ContactType_TimeStamp]
    FROM [dbo].[ContactTypes]
    	WHERE ([ContactType_ID] = @ContactType_ID)

    IF  @OldTimeStamp = @ContactType_TimeStamp
    BEGIN*/
		Update [dbo].[ContactTypes] SET 
		/*[ContactType_ID] =@ContactType_ID, 
		[ContactType_Code] =@ContactType_Code, 
		[ContactType_NameAr] =@ContactType_NameAr, 
		[ContactType_NameEn] =@ContactType_NameEn, 
		[ContactType_Notes] =@ContactType_Notes, 
		[ContactType_Search] =@ContactType_Search*/
		/*WHERE ([ContactType_ID] = @ContactType_ID)*/
	/*END*/

	/*SELECT @ContactType_RowNumber = [ContactType_RowNumber], @ContactType_TimeStamp = [ContactType_TimeStamp]
    FROM [dbo].[ContactTypes]
	WHERE ([ContactType_ID] = @ContactType_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ContactTypes-Insert-Update]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	Insert OR Update record into table [dbo].[ContactTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ContactTypes-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ContactTypes-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ContactTypes-Insert-Update]
	/*@ContactType_RowNumber int =Null OUTPUT , 
	@ContactType_ID uniqueidentifier =Null  , 
	@ContactType_Code varchar(50) =Null  , 
	@ContactType_NameAr varchar(300) =Null  , 
	@ContactType_NameEn varchar(300) =Null  , 
	@ContactType_Notes varchar(max) =Null  , 
	@ContactType_Search varchar(max) =Null  , 
	@ContactType_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[ContactTypes] 
					/*WHERE ([ContactType_ID] = @ContactType_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[ContactTypes](/*[ContactType_ID], [ContactType_Code], [ContactType_NameAr], [ContactType_NameEn], [ContactType_Notes], [ContactType_Search]*/)
		VALUES     (/*@ContactType_ID, @ContactType_Code, @ContactType_NameAr, @ContactType_NameEn, @ContactType_Notes, @ContactType_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [ContactType_TimeStamp]
		FROM [dbo].[ContactTypes]
    	WHERE ([ContactType_ID] = @ContactType_ID)

		IF  @OldTimeStamp = @ContactType_TimeStamp
		BEGIN*/
			Update [dbo].[ContactTypes] SET 
			/*[ContactType_ID] =@ContactType_ID, 
			[ContactType_Code] =@ContactType_Code, 
			[ContactType_NameAr] =@ContactType_NameAr, 
			[ContactType_NameEn] =@ContactType_NameEn, 
			[ContactType_Notes] =@ContactType_Notes, 
			[ContactType_Search] =@ContactType_Search*/
			/*WHERE ([ContactType_ID] = @ContactType_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @ContactType_RowNumber = [ContactType_RowNumber], @ContactType_TimeStamp = [ContactType_TimeStamp]
    FROM [dbo].[ContactTypes]
	WHERE ([ContactType_ID] = @ContactType_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ContactTypes-Delete]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	delete records from table [dbo].[ContactTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ContactTypes-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ContactTypes-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ContactTypes-Delete]
	/*@ContactType_RowNumber int =null  , 
	@ContactType_ID uniqueidentifier =null  , 
	@ContactType_Code varchar(50) =null  , 
	@ContactType_NameAr varchar(300) =null  , 
	@ContactType_NameEn varchar(300) =null  , 
	@ContactType_Notes varchar(max) =null  , 
	@ContactType_Search varchar(max) =null  , 
	@ContactType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[ContactTypes]
	WHERE /*( [ContactType_RowNumber] = ISNULL(@ContactType_RowNumber, [ContactType_RowNumber]) )
	AND ( [ContactType_ID] = ISNULL(@ContactType_ID, [ContactType_ID]) )
	AND ( [ContactType_Code] like ISNULL(@ContactType_Code, [ContactType_Code]) )
	AND ( [ContactType_NameAr] like ISNULL(@ContactType_NameAr, [ContactType_NameAr]) )
	AND ( [ContactType_NameEn] like ISNULL(@ContactType_NameEn, [ContactType_NameEn]) )
	AND ( [ContactType_Notes] like ISNULL(@ContactType_Notes, [ContactType_Notes]) )
	AND ( [ContactType_Search] like ISNULL(@ContactType_Search, [ContactType_Search]) )
	AND ( [ContactType_TimeStamp] = ISNULL(@ContactType_TimeStamp, [ContactType_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ContactTypes-Select]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	select records from table [dbo].[ContactTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ContactTypes-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ContactTypes-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ContactTypes-Select]
	/*@ContactType_RowNumber int =null  , 
	@ContactType_ID uniqueidentifier =null  , 
	@ContactType_Code varchar(50) =null  , 
	@ContactType_NameAr varchar(300) =null  , 
	@ContactType_NameEn varchar(300) =null  , 
	@ContactType_Notes varchar(max) =null  , 
	@ContactType_Search varchar(max) =null  , 
	@ContactType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[ContactTypes]
	WHERE /*( [ContactType_RowNumber] = ISNULL(@ContactType_RowNumber, [ContactType_RowNumber]) )
	AND ( [ContactType_ID] = ISNULL(@ContactType_ID, [ContactType_ID]) )
	AND ( [ContactType_Code] like ISNULL(@ContactType_Code, [ContactType_Code]) )
	AND ( [ContactType_NameAr] like ISNULL(@ContactType_NameAr, [ContactType_NameAr]) )
	AND ( [ContactType_NameEn] like ISNULL(@ContactType_NameEn, [ContactType_NameEn]) )
	AND ( [ContactType_Notes] like ISNULL(@ContactType_Notes, [ContactType_Notes]) )
	AND ( [ContactType_Search] like ISNULL(@ContactType_Search, [ContactType_Search]) )
	AND ( [ContactType_TimeStamp] = ISNULL(@ContactType_TimeStamp, [ContactType_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Countries-Insert]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	Insert record into table [dbo].[Countries]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Countries-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Countries-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Countries-Insert]
	/*@Country_RowNumber int =Null OUTPUT , 
	@Country_ID uniqueidentifier =Null  , 
	@Country_Code varchar(50) =Null  , 
	@Country_NameAr varchar(300) =Null  , 
	@Country_NameEn varchar(300) =Null  , 
	@Country_Notes varchar(max) =Null  , 
	@Country_Search varchar(max) =Null  , 
	@Country_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Countries](/*[Country_ID], [Country_Code], [Country_NameAr], [Country_NameEn], [Country_Notes], [Country_Search]*/)
	VALUES     (/*@Country_ID, @Country_Code, @Country_NameAr, @Country_NameEn, @Country_Notes, @Country_Search*/)

	/*SELECT @Country_RowNumber = [Country_RowNumber], @Country_TimeStamp = [Country_TimeStamp]
    FROM [dbo].[Countries]
    WHERE  ( [Country_ID] =@Country_ID )
	AND  ( [Country_Code] =@Country_Code )
	AND  ( [Country_NameAr] =@Country_NameAr )
	AND  ( [Country_NameEn] =@Country_NameEn )
	AND  ( [Country_Notes] =@Country_Notes )
	AND  ( [Country_Search] =@Country_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Countries-update]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	Update record in table [dbo].[Countries]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Countries-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Countries-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Countries-update]
	/*@Country_RowNumber int =Null OUTPUT , 
	@Country_ID uniqueidentifier =Null  , 
	@Country_Code varchar(50) =Null  , 
	@Country_NameAr varchar(300) =Null  , 
	@Country_NameEn varchar(300) =Null  , 
	@Country_Notes varchar(max) =Null  , 
	@Country_Search varchar(max) =Null  , 
	@Country_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Country_TimeStamp]
    FROM [dbo].[Countries]
    	WHERE ([Country_ID] = @Country_ID)

    IF  @OldTimeStamp = @Country_TimeStamp
    BEGIN*/
		Update [dbo].[Countries] SET 
		/*[Country_ID] =@Country_ID, 
		[Country_Code] =@Country_Code, 
		[Country_NameAr] =@Country_NameAr, 
		[Country_NameEn] =@Country_NameEn, 
		[Country_Notes] =@Country_Notes, 
		[Country_Search] =@Country_Search*/
		/*WHERE ([Country_ID] = @Country_ID)*/
	/*END*/

	/*SELECT @Country_RowNumber = [Country_RowNumber], @Country_TimeStamp = [Country_TimeStamp]
    FROM [dbo].[Countries]
	WHERE ([Country_ID] = @Country_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Countries-Insert-Update]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	Insert OR Update record into table [dbo].[Countries]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Countries-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Countries-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Countries-Insert-Update]
	/*@Country_RowNumber int =Null OUTPUT , 
	@Country_ID uniqueidentifier =Null  , 
	@Country_Code varchar(50) =Null  , 
	@Country_NameAr varchar(300) =Null  , 
	@Country_NameEn varchar(300) =Null  , 
	@Country_Notes varchar(max) =Null  , 
	@Country_Search varchar(max) =Null  , 
	@Country_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Countries] 
					/*WHERE ([Country_ID] = @Country_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Countries](/*[Country_ID], [Country_Code], [Country_NameAr], [Country_NameEn], [Country_Notes], [Country_Search]*/)
		VALUES     (/*@Country_ID, @Country_Code, @Country_NameAr, @Country_NameEn, @Country_Notes, @Country_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Country_TimeStamp]
		FROM [dbo].[Countries]
    	WHERE ([Country_ID] = @Country_ID)

		IF  @OldTimeStamp = @Country_TimeStamp
		BEGIN*/
			Update [dbo].[Countries] SET 
			/*[Country_ID] =@Country_ID, 
			[Country_Code] =@Country_Code, 
			[Country_NameAr] =@Country_NameAr, 
			[Country_NameEn] =@Country_NameEn, 
			[Country_Notes] =@Country_Notes, 
			[Country_Search] =@Country_Search*/
			/*WHERE ([Country_ID] = @Country_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Country_RowNumber = [Country_RowNumber], @Country_TimeStamp = [Country_TimeStamp]
    FROM [dbo].[Countries]
	WHERE ([Country_ID] = @Country_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Countries-Delete]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	delete records from table [dbo].[Countries] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Countries-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Countries-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Countries-Delete]
	/*@Country_RowNumber int =null  , 
	@Country_ID uniqueidentifier =null  , 
	@Country_Code varchar(50) =null  , 
	@Country_NameAr varchar(300) =null  , 
	@Country_NameEn varchar(300) =null  , 
	@Country_Notes varchar(max) =null  , 
	@Country_Search varchar(max) =null  , 
	@Country_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Countries]
	WHERE /*( [Country_RowNumber] = ISNULL(@Country_RowNumber, [Country_RowNumber]) )
	AND ( [Country_ID] = ISNULL(@Country_ID, [Country_ID]) )
	AND ( [Country_Code] like ISNULL(@Country_Code, [Country_Code]) )
	AND ( [Country_NameAr] like ISNULL(@Country_NameAr, [Country_NameAr]) )
	AND ( [Country_NameEn] like ISNULL(@Country_NameEn, [Country_NameEn]) )
	AND ( [Country_Notes] like ISNULL(@Country_Notes, [Country_Notes]) )
	AND ( [Country_Search] like ISNULL(@Country_Search, [Country_Search]) )
	AND ( [Country_TimeStamp] = ISNULL(@Country_TimeStamp, [Country_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Countries-Select]    Script Date: [[20120914064950]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064950]]
-- Description:	select records from table [dbo].[Countries] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Countries-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Countries-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Countries-Select]
	/*@Country_RowNumber int =null  , 
	@Country_ID uniqueidentifier =null  , 
	@Country_Code varchar(50) =null  , 
	@Country_NameAr varchar(300) =null  , 
	@Country_NameEn varchar(300) =null  , 
	@Country_Notes varchar(max) =null  , 
	@Country_Search varchar(max) =null  , 
	@Country_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Countries]
	WHERE /*( [Country_RowNumber] = ISNULL(@Country_RowNumber, [Country_RowNumber]) )
	AND ( [Country_ID] = ISNULL(@Country_ID, [Country_ID]) )
	AND ( [Country_Code] like ISNULL(@Country_Code, [Country_Code]) )
	AND ( [Country_NameAr] like ISNULL(@Country_NameAr, [Country_NameAr]) )
	AND ( [Country_NameEn] like ISNULL(@Country_NameEn, [Country_NameEn]) )
	AND ( [Country_Notes] like ISNULL(@Country_Notes, [Country_Notes]) )
	AND ( [Country_Search] like ISNULL(@Country_Search, [Country_Search]) )
	AND ( [Country_TimeStamp] = ISNULL(@Country_TimeStamp, [Country_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers-Insert]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	Insert record into table [dbo].[Dealers]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers-Insert]
	/*@Dealer_RowNumber int =Null OUTPUT , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Dealer_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@Dealer_NameAr varchar(300) =Null  , 
	@Dealer_NameEn varchar(300) =Null  , 
	@Importance_ID uniqueidentifier =Null  , 
	@TypeOfTrade_ID uniqueidentifier =Null  , 
	@Dealer_StartDate datetime =Null  , 
	@Dealer_Notes varchar(max) =Null  , 
	@Dealer_Search varchar(max) =Null  , 
	@Dealer_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Dealers](/*[Dealer_ID], [Dealer_Code], [DealerType_ID], [DealerClassification_ID], [Dealer_NameAr], [Dealer_NameEn], [Importance_ID], [TypeOfTrade_ID], [Dealer_StartDate], [Dealer_Notes], [Dealer_Search]*/)
	VALUES     (/*@Dealer_ID, @Dealer_Code, @DealerType_ID, @DealerClassification_ID, @Dealer_NameAr, @Dealer_NameEn, @Importance_ID, @TypeOfTrade_ID, @Dealer_StartDate, @Dealer_Notes, @Dealer_Search*/)

	/*SELECT @Dealer_RowNumber = [Dealer_RowNumber], @Dealer_TimeStamp = [Dealer_TimeStamp]
    FROM [dbo].[Dealers]
    WHERE  ( [Dealer_ID] =@Dealer_ID )
	AND  ( [Dealer_Code] =@Dealer_Code )
	AND  ( [DealerType_ID] =@DealerType_ID )
	AND  ( [DealerClassification_ID] =@DealerClassification_ID )
	AND  ( [Dealer_NameAr] =@Dealer_NameAr )
	AND  ( [Dealer_NameEn] =@Dealer_NameEn )
	AND  ( [Importance_ID] =@Importance_ID )
	AND  ( [TypeOfTrade_ID] =@TypeOfTrade_ID )
	AND  ( [Dealer_StartDate] =@Dealer_StartDate )
	AND  ( [Dealer_Notes] =@Dealer_Notes )
	AND  ( [Dealer_Search] =@Dealer_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers-update]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	Update record in table [dbo].[Dealers]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers-update]
	/*@Dealer_RowNumber int =Null OUTPUT , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Dealer_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@Dealer_NameAr varchar(300) =Null  , 
	@Dealer_NameEn varchar(300) =Null  , 
	@Importance_ID uniqueidentifier =Null  , 
	@TypeOfTrade_ID uniqueidentifier =Null  , 
	@Dealer_StartDate datetime =Null  , 
	@Dealer_Notes varchar(max) =Null  , 
	@Dealer_Search varchar(max) =Null  , 
	@Dealer_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Dealer_TimeStamp]
    FROM [dbo].[Dealers]
    	WHERE ([Dealer_ID] = @Dealer_ID)

    IF  @OldTimeStamp = @Dealer_TimeStamp
    BEGIN*/
		Update [dbo].[Dealers] SET 
		/*[Dealer_ID] =@Dealer_ID, 
		[Dealer_Code] =@Dealer_Code, 
		[DealerType_ID] =@DealerType_ID, 
		[DealerClassification_ID] =@DealerClassification_ID, 
		[Dealer_NameAr] =@Dealer_NameAr, 
		[Dealer_NameEn] =@Dealer_NameEn, 
		[Importance_ID] =@Importance_ID, 
		[TypeOfTrade_ID] =@TypeOfTrade_ID, 
		[Dealer_StartDate] =@Dealer_StartDate, 
		[Dealer_Notes] =@Dealer_Notes, 
		[Dealer_Search] =@Dealer_Search*/
		/*WHERE ([Dealer_ID] = @Dealer_ID)*/
	/*END*/

	/*SELECT @Dealer_RowNumber = [Dealer_RowNumber], @Dealer_TimeStamp = [Dealer_TimeStamp]
    FROM [dbo].[Dealers]
	WHERE ([Dealer_ID] = @Dealer_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers-Insert-Update]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	Insert OR Update record into table [dbo].[Dealers]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers-Insert-Update]
	/*@Dealer_RowNumber int =Null OUTPUT , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Dealer_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@Dealer_NameAr varchar(300) =Null  , 
	@Dealer_NameEn varchar(300) =Null  , 
	@Importance_ID uniqueidentifier =Null  , 
	@TypeOfTrade_ID uniqueidentifier =Null  , 
	@Dealer_StartDate datetime =Null  , 
	@Dealer_Notes varchar(max) =Null  , 
	@Dealer_Search varchar(max) =Null  , 
	@Dealer_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Dealers] 
					/*WHERE ([Dealer_ID] = @Dealer_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Dealers](/*[Dealer_ID], [Dealer_Code], [DealerType_ID], [DealerClassification_ID], [Dealer_NameAr], [Dealer_NameEn], [Importance_ID], [TypeOfTrade_ID], [Dealer_StartDate], [Dealer_Notes], [Dealer_Search]*/)
		VALUES     (/*@Dealer_ID, @Dealer_Code, @DealerType_ID, @DealerClassification_ID, @Dealer_NameAr, @Dealer_NameEn, @Importance_ID, @TypeOfTrade_ID, @Dealer_StartDate, @Dealer_Notes, @Dealer_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Dealer_TimeStamp]
		FROM [dbo].[Dealers]
    	WHERE ([Dealer_ID] = @Dealer_ID)

		IF  @OldTimeStamp = @Dealer_TimeStamp
		BEGIN*/
			Update [dbo].[Dealers] SET 
			/*[Dealer_ID] =@Dealer_ID, 
			[Dealer_Code] =@Dealer_Code, 
			[DealerType_ID] =@DealerType_ID, 
			[DealerClassification_ID] =@DealerClassification_ID, 
			[Dealer_NameAr] =@Dealer_NameAr, 
			[Dealer_NameEn] =@Dealer_NameEn, 
			[Importance_ID] =@Importance_ID, 
			[TypeOfTrade_ID] =@TypeOfTrade_ID, 
			[Dealer_StartDate] =@Dealer_StartDate, 
			[Dealer_Notes] =@Dealer_Notes, 
			[Dealer_Search] =@Dealer_Search*/
			/*WHERE ([Dealer_ID] = @Dealer_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Dealer_RowNumber = [Dealer_RowNumber], @Dealer_TimeStamp = [Dealer_TimeStamp]
    FROM [dbo].[Dealers]
	WHERE ([Dealer_ID] = @Dealer_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers-Delete]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	delete records from table [dbo].[Dealers] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers-Delete]
	/*@Dealer_RowNumber int =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Dealer_Code varchar(50) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerClassification_ID uniqueidentifier =null  , 
	@Dealer_NameAr varchar(300) =null  , 
	@Dealer_NameEn varchar(300) =null  , 
	@Importance_ID uniqueidentifier =null  , 
	@TypeOfTrade_ID uniqueidentifier =null  , 
	@Dealer_StartDate datetime =null  , 
	@Dealer_Notes varchar(max) =null  , 
	@Dealer_Search varchar(max) =null  , 
	@Dealer_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Dealers]
	WHERE /*( [Dealer_RowNumber] = ISNULL(@Dealer_RowNumber, [Dealer_RowNumber]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Dealer_Code] like ISNULL(@Dealer_Code, [Dealer_Code]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerClassification_ID] = ISNULL(@DealerClassification_ID, [DealerClassification_ID]) )
	AND ( [Dealer_NameAr] like ISNULL(@Dealer_NameAr, [Dealer_NameAr]) )
	AND ( [Dealer_NameEn] like ISNULL(@Dealer_NameEn, [Dealer_NameEn]) )
	AND ( [Importance_ID] = ISNULL(@Importance_ID, [Importance_ID]) )
	AND ( [TypeOfTrade_ID] = ISNULL(@TypeOfTrade_ID, [TypeOfTrade_ID]) )
	AND ( [Dealer_StartDate] = ISNULL(@Dealer_StartDate, [Dealer_StartDate]) )
	AND ( [Dealer_Notes] like ISNULL(@Dealer_Notes, [Dealer_Notes]) )
	AND ( [Dealer_Search] like ISNULL(@Dealer_Search, [Dealer_Search]) )
	AND ( [Dealer_TimeStamp] = ISNULL(@Dealer_TimeStamp, [Dealer_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers-Select]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	select records from table [dbo].[Dealers] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers-Select]
	/*@Dealer_RowNumber int =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Dealer_Code varchar(50) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerClassification_ID uniqueidentifier =null  , 
	@Dealer_NameAr varchar(300) =null  , 
	@Dealer_NameEn varchar(300) =null  , 
	@Importance_ID uniqueidentifier =null  , 
	@TypeOfTrade_ID uniqueidentifier =null  , 
	@Dealer_StartDate datetime =null  , 
	@Dealer_Notes varchar(max) =null  , 
	@Dealer_Search varchar(max) =null  , 
	@Dealer_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Dealers]
	WHERE /*( [Dealer_RowNumber] = ISNULL(@Dealer_RowNumber, [Dealer_RowNumber]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Dealer_Code] like ISNULL(@Dealer_Code, [Dealer_Code]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerClassification_ID] = ISNULL(@DealerClassification_ID, [DealerClassification_ID]) )
	AND ( [Dealer_NameAr] like ISNULL(@Dealer_NameAr, [Dealer_NameAr]) )
	AND ( [Dealer_NameEn] like ISNULL(@Dealer_NameEn, [Dealer_NameEn]) )
	AND ( [Importance_ID] = ISNULL(@Importance_ID, [Importance_ID]) )
	AND ( [TypeOfTrade_ID] = ISNULL(@TypeOfTrade_ID, [TypeOfTrade_ID]) )
	AND ( [Dealer_StartDate] = ISNULL(@Dealer_StartDate, [Dealer_StartDate]) )
	AND ( [Dealer_Notes] like ISNULL(@Dealer_Notes, [Dealer_Notes]) )
	AND ( [Dealer_Search] like ISNULL(@Dealer_Search, [Dealer_Search]) )
	AND ( [Dealer_TimeStamp] = ISNULL(@Dealer_TimeStamp, [Dealer_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Banks-Insert]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	Insert record into table [dbo].[Dealers_Banks]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Banks-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Banks-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Banks-Insert]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Bank_ID uniqueidentifier =Null  , 
	@AcountNumber varchar(100) =Null  , 
	@Dealer_Bank_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Dealers_Banks](/*[ID], [Dealer_ID], [Bank_ID], [AcountNumber]*/)
	VALUES     (/*@ID, @Dealer_ID, @Bank_ID, @AcountNumber*/)

	/*SELECT @RowNumber = [RowNumber], @Dealer_Bank_TimeStamp = [Dealer_Bank_TimeStamp]
    FROM [dbo].[Dealers_Banks]
    WHERE  ( [ID] =@ID )
	AND  ( [Dealer_ID] =@Dealer_ID )
	AND  ( [Bank_ID] =@Bank_ID )
	AND  ( [AcountNumber] =@AcountNumber )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Banks-update]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	Update record in table [dbo].[Dealers_Banks]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Banks-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Banks-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Banks-update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Bank_ID uniqueidentifier =Null  , 
	@AcountNumber varchar(100) =Null  , 
	@Dealer_Bank_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Dealer_Bank_TimeStamp]
    FROM [dbo].[Dealers_Banks]
    	WHERE ([ID] = @ID)

    IF  @OldTimeStamp = @Dealer_Bank_TimeStamp
    BEGIN*/
		Update [dbo].[Dealers_Banks] SET 
		/*[ID] =@ID, 
		[Dealer_ID] =@Dealer_ID, 
		[Bank_ID] =@Bank_ID, 
		[AcountNumber] =@AcountNumber*/
		/*WHERE ([ID] = @ID)*/
	/*END*/

	/*SELECT @RowNumber = [RowNumber], @Dealer_Bank_TimeStamp = [Dealer_Bank_TimeStamp]
    FROM [dbo].[Dealers_Banks]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Banks-Insert-Update]    Script Date: [[20120914064951]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064951]]
-- Description:	Insert OR Update record into table [dbo].[Dealers_Banks]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Banks-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Banks-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Banks-Insert-Update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Bank_ID uniqueidentifier =Null  , 
	@AcountNumber varchar(100) =Null  , 
	@Dealer_Bank_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Dealers_Banks] 
					/*WHERE ([ID] = @ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Dealers_Banks](/*[ID], [Dealer_ID], [Bank_ID], [AcountNumber]*/)
		VALUES     (/*@ID, @Dealer_ID, @Bank_ID, @AcountNumber*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Dealer_Bank_TimeStamp]
		FROM [dbo].[Dealers_Banks]
    	WHERE ([ID] = @ID)

		IF  @OldTimeStamp = @Dealer_Bank_TimeStamp
		BEGIN*/
			Update [dbo].[Dealers_Banks] SET 
			/*[ID] =@ID, 
			[Dealer_ID] =@Dealer_ID, 
			[Bank_ID] =@Bank_ID, 
			[AcountNumber] =@AcountNumber*/
			/*WHERE ([ID] = @ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @RowNumber = [RowNumber], @Dealer_Bank_TimeStamp = [Dealer_Bank_TimeStamp]
    FROM [dbo].[Dealers_Banks]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Banks-Delete]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	delete records from table [dbo].[Dealers_Banks] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Banks-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Banks-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Banks-Delete]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Bank_ID uniqueidentifier =null  , 
	@AcountNumber varchar(100) =null  , 
	@Dealer_Bank_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Dealers_Banks]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Bank_ID] = ISNULL(@Bank_ID, [Bank_ID]) )
	AND ( [AcountNumber] like ISNULL(@AcountNumber, [AcountNumber]) )
	AND ( [Dealer_Bank_TimeStamp] = ISNULL(@Dealer_Bank_TimeStamp, [Dealer_Bank_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Banks-Select]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	select records from table [dbo].[Dealers_Banks] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Banks-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Banks-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Banks-Select]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Bank_ID uniqueidentifier =null  , 
	@AcountNumber varchar(100) =null  , 
	@Dealer_Bank_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Dealers_Banks]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Bank_ID] = ISNULL(@Bank_ID, [Bank_ID]) )
	AND ( [AcountNumber] like ISNULL(@AcountNumber, [AcountNumber]) )
	AND ( [Dealer_Bank_TimeStamp] = ISNULL(@Dealer_Bank_TimeStamp, [Dealer_Bank_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Products-Insert]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	Insert record into table [dbo].[Dealers_Products]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Products-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Products-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Products-Insert]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Product_ID uniqueidentifier =Null  , 
	@Is_Supplier tinyint =0  , 
	@Dealer_Product_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Dealers_Products](/*[ID], [Dealer_ID], [Product_ID], [Is_Supplier]*/)
	VALUES     (/*@ID, @Dealer_ID, @Product_ID, @Is_Supplier*/)

	/*SELECT @RowNumber = [RowNumber], @Dealer_Product_TimeStamp = [Dealer_Product_TimeStamp]
    FROM [dbo].[Dealers_Products]
    WHERE  ( [ID] =@ID )
	AND  ( [Dealer_ID] =@Dealer_ID )
	AND  ( [Product_ID] =@Product_ID )
	AND  ( [Is_Supplier] =@Is_Supplier )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Products-update]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	Update record in table [dbo].[Dealers_Products]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Products-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Products-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Products-update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Product_ID uniqueidentifier =Null  , 
	@Is_Supplier tinyint =0  , 
	@Dealer_Product_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Dealer_Product_TimeStamp]
    FROM [dbo].[Dealers_Products]
    	WHERE ([ID] = @ID)

    IF  @OldTimeStamp = @Dealer_Product_TimeStamp
    BEGIN*/
		Update [dbo].[Dealers_Products] SET 
		/*[ID] =@ID, 
		[Dealer_ID] =@Dealer_ID, 
		[Product_ID] =@Product_ID, 
		[Is_Supplier] =@Is_Supplier*/
		/*WHERE ([ID] = @ID)*/
	/*END*/

	/*SELECT @RowNumber = [RowNumber], @Dealer_Product_TimeStamp = [Dealer_Product_TimeStamp]
    FROM [dbo].[Dealers_Products]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Products-Insert-Update]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	Insert OR Update record into table [dbo].[Dealers_Products]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Products-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Products-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Products-Insert-Update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Product_ID uniqueidentifier =Null  , 
	@Is_Supplier tinyint =0  , 
	@Dealer_Product_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Dealers_Products] 
					/*WHERE ([ID] = @ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Dealers_Products](/*[ID], [Dealer_ID], [Product_ID], [Is_Supplier]*/)
		VALUES     (/*@ID, @Dealer_ID, @Product_ID, @Is_Supplier*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Dealer_Product_TimeStamp]
		FROM [dbo].[Dealers_Products]
    	WHERE ([ID] = @ID)

		IF  @OldTimeStamp = @Dealer_Product_TimeStamp
		BEGIN*/
			Update [dbo].[Dealers_Products] SET 
			/*[ID] =@ID, 
			[Dealer_ID] =@Dealer_ID, 
			[Product_ID] =@Product_ID, 
			[Is_Supplier] =@Is_Supplier*/
			/*WHERE ([ID] = @ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @RowNumber = [RowNumber], @Dealer_Product_TimeStamp = [Dealer_Product_TimeStamp]
    FROM [dbo].[Dealers_Products]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Products-Delete]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	delete records from table [dbo].[Dealers_Products] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Products-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Products-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Products-Delete]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Product_ID uniqueidentifier =null  , 
	@Is_Supplier tinyint =null  , 
	@Dealer_Product_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Dealers_Products]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Product_ID] = ISNULL(@Product_ID, [Product_ID]) )
	AND ( [Is_Supplier] = ISNULL(@Is_Supplier, [Is_Supplier]) )
	AND ( [Dealer_Product_TimeStamp] = ISNULL(@Dealer_Product_TimeStamp, [Dealer_Product_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Dealers_Products-Select]    Script Date: [[20120914064952]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064952]]
-- Description:	select records from table [dbo].[Dealers_Products] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Dealers_Products-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Dealers_Products-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Dealers_Products-Select]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Product_ID uniqueidentifier =null  , 
	@Is_Supplier tinyint =null  , 
	@Dealer_Product_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Dealers_Products]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Product_ID] = ISNULL(@Product_ID, [Product_ID]) )
	AND ( [Is_Supplier] = ISNULL(@Is_Supplier, [Is_Supplier]) )
	AND ( [Dealer_Product_TimeStamp] = ISNULL(@Dealer_Product_TimeStamp, [Dealer_Product_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersAttachments-Insert]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Insert record into table [dbo].[DealersAttachments]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersAttachments-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersAttachments-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersAttachments-Insert]
	/*@DealerAttachment_RowNumber int =Null OUTPUT , 
	@DealerAttachment_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@File_DisplayName varchar(100) =Null  , 
	@File_Path varchar(max) =Null  , 
	@Is_Encrypted tinyint =0  , 
	@File_Bytes varbinary =Null  , 
	@File_Notes varchar(max) =Null  , 
	@File_Search varchar(max) =Null  , 
	@Mime_ID uniqueidentifier =Null  , 
	@DealerAttachment_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[DealersAttachments](/*[DealerAttachment_ID], [Dealer_ID], [File_DisplayName], [File_Path], [Is_Encrypted], [File_Bytes], [File_Notes], [File_Search], [Mime_ID]*/)
	VALUES     (/*@DealerAttachment_ID, @Dealer_ID, @File_DisplayName, @File_Path, @Is_Encrypted, @File_Bytes, @File_Notes, @File_Search, @Mime_ID*/)

	/*SELECT @DealerAttachment_RowNumber = [DealerAttachment_RowNumber], @DealerAttachment_TimeStamp = [DealerAttachment_TimeStamp]
    FROM [dbo].[DealersAttachments]
    WHERE  ( [DealerAttachment_ID] =@DealerAttachment_ID )
	AND  ( [Dealer_ID] =@Dealer_ID )
	AND  ( [File_DisplayName] =@File_DisplayName )
	AND  ( [File_Path] =@File_Path )
	AND  ( [Is_Encrypted] =@Is_Encrypted )
	AND  ( [File_Bytes] =@File_Bytes )
	AND  ( [File_Notes] =@File_Notes )
	AND  ( [File_Search] =@File_Search )
	AND  ( [Mime_ID] =@Mime_ID )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersAttachments-update]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Update record in table [dbo].[DealersAttachments]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersAttachments-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersAttachments-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersAttachments-update]
	/*@DealerAttachment_RowNumber int =Null OUTPUT , 
	@DealerAttachment_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@File_DisplayName varchar(100) =Null  , 
	@File_Path varchar(max) =Null  , 
	@Is_Encrypted tinyint =0  , 
	@File_Bytes varbinary =Null  , 
	@File_Notes varchar(max) =Null  , 
	@File_Search varchar(max) =Null  , 
	@Mime_ID uniqueidentifier =Null  , 
	@DealerAttachment_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [DealerAttachment_TimeStamp]
    FROM [dbo].[DealersAttachments]
    	WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)

    IF  @OldTimeStamp = @DealerAttachment_TimeStamp
    BEGIN*/
		Update [dbo].[DealersAttachments] SET 
		/*[DealerAttachment_ID] =@DealerAttachment_ID, 
		[Dealer_ID] =@Dealer_ID, 
		[File_DisplayName] =@File_DisplayName, 
		[File_Path] =@File_Path, 
		[Is_Encrypted] =@Is_Encrypted, 
		[File_Bytes] =@File_Bytes, 
		[File_Notes] =@File_Notes, 
		[File_Search] =@File_Search, 
		[Mime_ID] =@Mime_ID*/
		/*WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)*/
	/*END*/

	/*SELECT @DealerAttachment_RowNumber = [DealerAttachment_RowNumber], @DealerAttachment_TimeStamp = [DealerAttachment_TimeStamp]
    FROM [dbo].[DealersAttachments]
	WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersAttachments-Insert-Update]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Insert OR Update record into table [dbo].[DealersAttachments]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersAttachments-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersAttachments-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersAttachments-Insert-Update]
	/*@DealerAttachment_RowNumber int =Null OUTPUT , 
	@DealerAttachment_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@File_DisplayName varchar(100) =Null  , 
	@File_Path varchar(max) =Null  , 
	@Is_Encrypted tinyint =0  , 
	@File_Bytes varbinary =Null  , 
	@File_Notes varchar(max) =Null  , 
	@File_Search varchar(max) =Null  , 
	@Mime_ID uniqueidentifier =Null  , 
	@DealerAttachment_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[DealersAttachments] 
					/*WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[DealersAttachments](/*[DealerAttachment_ID], [Dealer_ID], [File_DisplayName], [File_Path], [Is_Encrypted], [File_Bytes], [File_Notes], [File_Search], [Mime_ID]*/)
		VALUES     (/*@DealerAttachment_ID, @Dealer_ID, @File_DisplayName, @File_Path, @Is_Encrypted, @File_Bytes, @File_Notes, @File_Search, @Mime_ID*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [DealerAttachment_TimeStamp]
		FROM [dbo].[DealersAttachments]
    	WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)

		IF  @OldTimeStamp = @DealerAttachment_TimeStamp
		BEGIN*/
			Update [dbo].[DealersAttachments] SET 
			/*[DealerAttachment_ID] =@DealerAttachment_ID, 
			[Dealer_ID] =@Dealer_ID, 
			[File_DisplayName] =@File_DisplayName, 
			[File_Path] =@File_Path, 
			[Is_Encrypted] =@Is_Encrypted, 
			[File_Bytes] =@File_Bytes, 
			[File_Notes] =@File_Notes, 
			[File_Search] =@File_Search, 
			[Mime_ID] =@Mime_ID*/
			/*WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @DealerAttachment_RowNumber = [DealerAttachment_RowNumber], @DealerAttachment_TimeStamp = [DealerAttachment_TimeStamp]
    FROM [dbo].[DealersAttachments]
	WHERE ([DealerAttachment_ID] = @DealerAttachment_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersAttachments-Delete]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	delete records from table [dbo].[DealersAttachments] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersAttachments-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersAttachments-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersAttachments-Delete]
	/*@DealerAttachment_RowNumber int =null  , 
	@DealerAttachment_ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@File_DisplayName varchar(100) =null  , 
	@File_Path varchar(max) =null  , 
	@Is_Encrypted tinyint =null  , 
	@File_Bytes varbinary =null  , 
	@File_Notes varchar(max) =null  , 
	@File_Search varchar(max) =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@DealerAttachment_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[DealersAttachments]
	WHERE /*( [DealerAttachment_RowNumber] = ISNULL(@DealerAttachment_RowNumber, [DealerAttachment_RowNumber]) )
	AND ( [DealerAttachment_ID] = ISNULL(@DealerAttachment_ID, [DealerAttachment_ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [File_DisplayName] like ISNULL(@File_DisplayName, [File_DisplayName]) )
	AND ( [File_Path] like ISNULL(@File_Path, [File_Path]) )
	AND ( [Is_Encrypted] = ISNULL(@Is_Encrypted, [Is_Encrypted]) )
	AND ( [File_Bytes] = ISNULL(@File_Bytes, [File_Bytes]) )
	AND ( [File_Notes] like ISNULL(@File_Notes, [File_Notes]) )
	AND ( [File_Search] like ISNULL(@File_Search, [File_Search]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [DealerAttachment_TimeStamp] = ISNULL(@DealerAttachment_TimeStamp, [DealerAttachment_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersAttachments-Select]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	select records from table [dbo].[DealersAttachments] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersAttachments-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersAttachments-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersAttachments-Select]
	/*@DealerAttachment_RowNumber int =null  , 
	@DealerAttachment_ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@File_DisplayName varchar(100) =null  , 
	@File_Path varchar(max) =null  , 
	@Is_Encrypted tinyint =null  , 
	@File_Bytes varbinary =null  , 
	@File_Notes varchar(max) =null  , 
	@File_Search varchar(max) =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@DealerAttachment_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[DealersAttachments]
	WHERE /*( [DealerAttachment_RowNumber] = ISNULL(@DealerAttachment_RowNumber, [DealerAttachment_RowNumber]) )
	AND ( [DealerAttachment_ID] = ISNULL(@DealerAttachment_ID, [DealerAttachment_ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [File_DisplayName] like ISNULL(@File_DisplayName, [File_DisplayName]) )
	AND ( [File_Path] like ISNULL(@File_Path, [File_Path]) )
	AND ( [Is_Encrypted] = ISNULL(@Is_Encrypted, [Is_Encrypted]) )
	AND ( [File_Bytes] = ISNULL(@File_Bytes, [File_Bytes]) )
	AND ( [File_Notes] like ISNULL(@File_Notes, [File_Notes]) )
	AND ( [File_Search] like ISNULL(@File_Search, [File_Search]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [DealerAttachment_TimeStamp] = ISNULL(@DealerAttachment_TimeStamp, [DealerAttachment_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Insert]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Insert record into table [dbo].[DealersClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Insert]
	/*@DealerClassification_RowNumber int =Null OUTPUT , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@DealerClassification_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_NameAr varchar(300) =Null  , 
	@DealerClassification_NameEn varchar(300) =Null  , 
	@DealerClassification_Notes varchar(max) =Null  , 
	@DealerClassification_Search varchar(max) =Null  , 
	@DealerClassification_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[DealersClassifications](/*[DealerClassification_ID], [DealerClassification_Code], [DealerType_ID], [DealerClassification_NameAr], [DealerClassification_NameEn], [DealerClassification_Notes], [DealerClassification_Search]*/)
	VALUES     (/*@DealerClassification_ID, @DealerClassification_Code, @DealerType_ID, @DealerClassification_NameAr, @DealerClassification_NameEn, @DealerClassification_Notes, @DealerClassification_Search*/)

	/*SELECT @DealerClassification_RowNumber = [DealerClassification_RowNumber], @DealerClassification_TimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
    WHERE  ( [DealerClassification_ID] =@DealerClassification_ID )
	AND  ( [DealerClassification_Code] =@DealerClassification_Code )
	AND  ( [DealerType_ID] =@DealerType_ID )
	AND  ( [DealerClassification_NameAr] =@DealerClassification_NameAr )
	AND  ( [DealerClassification_NameEn] =@DealerClassification_NameEn )
	AND  ( [DealerClassification_Notes] =@DealerClassification_Notes )
	AND  ( [DealerClassification_Search] =@DealerClassification_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-update]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Update record in table [dbo].[DealersClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-update]
	/*@DealerClassification_RowNumber int =Null OUTPUT , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@DealerClassification_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_NameAr varchar(300) =Null  , 
	@DealerClassification_NameEn varchar(300) =Null  , 
	@DealerClassification_Notes varchar(max) =Null  , 
	@DealerClassification_Search varchar(max) =Null  , 
	@DealerClassification_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
    	WHERE ([DealerClassification_ID] = @DealerClassification_ID)

    IF  @OldTimeStamp = @DealerClassification_TimeStamp
    BEGIN*/
		Update [dbo].[DealersClassifications] SET 
		/*[DealerClassification_ID] =@DealerClassification_ID, 
		[DealerClassification_Code] =@DealerClassification_Code, 
		[DealerType_ID] =@DealerType_ID, 
		[DealerClassification_NameAr] =@DealerClassification_NameAr, 
		[DealerClassification_NameEn] =@DealerClassification_NameEn, 
		[DealerClassification_Notes] =@DealerClassification_Notes, 
		[DealerClassification_Search] =@DealerClassification_Search*/
		/*WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
	/*END*/

	/*SELECT @DealerClassification_RowNumber = [DealerClassification_RowNumber], @DealerClassification_TimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
	WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Insert-Update]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Insert OR Update record into table [dbo].[DealersClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Insert-Update]
	/*@DealerClassification_RowNumber int =Null OUTPUT , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@DealerClassification_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_NameAr varchar(300) =Null  , 
	@DealerClassification_NameEn varchar(300) =Null  , 
	@DealerClassification_Notes varchar(max) =Null  , 
	@DealerClassification_Search varchar(max) =Null  , 
	@DealerClassification_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[DealersClassifications] 
					/*WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[DealersClassifications](/*[DealerClassification_ID], [DealerClassification_Code], [DealerType_ID], [DealerClassification_NameAr], [DealerClassification_NameEn], [DealerClassification_Notes], [DealerClassification_Search]*/)
		VALUES     (/*@DealerClassification_ID, @DealerClassification_Code, @DealerType_ID, @DealerClassification_NameAr, @DealerClassification_NameEn, @DealerClassification_Notes, @DealerClassification_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [DealerClassification_TimeStamp]
		FROM [dbo].[DealersClassifications]
    	WHERE ([DealerClassification_ID] = @DealerClassification_ID)

		IF  @OldTimeStamp = @DealerClassification_TimeStamp
		BEGIN*/
			Update [dbo].[DealersClassifications] SET 
			/*[DealerClassification_ID] =@DealerClassification_ID, 
			[DealerClassification_Code] =@DealerClassification_Code, 
			[DealerType_ID] =@DealerType_ID, 
			[DealerClassification_NameAr] =@DealerClassification_NameAr, 
			[DealerClassification_NameEn] =@DealerClassification_NameEn, 
			[DealerClassification_Notes] =@DealerClassification_Notes, 
			[DealerClassification_Search] =@DealerClassification_Search*/
			/*WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @DealerClassification_RowNumber = [DealerClassification_RowNumber], @DealerClassification_TimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
	WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Delete]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	delete records from table [dbo].[DealersClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Delete]
	/*@DealerClassification_RowNumber int =null  , 
	@DealerClassification_ID uniqueidentifier =null  , 
	@DealerClassification_Code varchar(50) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerClassification_NameAr varchar(300) =null  , 
	@DealerClassification_NameEn varchar(300) =null  , 
	@DealerClassification_Notes varchar(max) =null  , 
	@DealerClassification_Search varchar(max) =null  , 
	@DealerClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[DealersClassifications]
	WHERE /*( [DealerClassification_RowNumber] = ISNULL(@DealerClassification_RowNumber, [DealerClassification_RowNumber]) )
	AND ( [DealerClassification_ID] = ISNULL(@DealerClassification_ID, [DealerClassification_ID]) )
	AND ( [DealerClassification_Code] like ISNULL(@DealerClassification_Code, [DealerClassification_Code]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerClassification_NameAr] like ISNULL(@DealerClassification_NameAr, [DealerClassification_NameAr]) )
	AND ( [DealerClassification_NameEn] like ISNULL(@DealerClassification_NameEn, [DealerClassification_NameEn]) )
	AND ( [DealerClassification_Notes] like ISNULL(@DealerClassification_Notes, [DealerClassification_Notes]) )
	AND ( [DealerClassification_Search] like ISNULL(@DealerClassification_Search, [DealerClassification_Search]) )
	AND ( [DealerClassification_TimeStamp] = ISNULL(@DealerClassification_TimeStamp, [DealerClassification_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Select]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	select records from table [dbo].[DealersClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Select]
	/*@DealerClassification_RowNumber int =null  , 
	@DealerClassification_ID uniqueidentifier =null  , 
	@DealerClassification_Code varchar(50) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerClassification_NameAr varchar(300) =null  , 
	@DealerClassification_NameEn varchar(300) =null  , 
	@DealerClassification_Notes varchar(max) =null  , 
	@DealerClassification_Search varchar(max) =null  , 
	@DealerClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[DealersClassifications]
	WHERE /*( [DealerClassification_RowNumber] = ISNULL(@DealerClassification_RowNumber, [DealerClassification_RowNumber]) )
	AND ( [DealerClassification_ID] = ISNULL(@DealerClassification_ID, [DealerClassification_ID]) )
	AND ( [DealerClassification_Code] like ISNULL(@DealerClassification_Code, [DealerClassification_Code]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerClassification_NameAr] like ISNULL(@DealerClassification_NameAr, [DealerClassification_NameAr]) )
	AND ( [DealerClassification_NameEn] like ISNULL(@DealerClassification_NameEn, [DealerClassification_NameEn]) )
	AND ( [DealerClassification_Notes] like ISNULL(@DealerClassification_Notes, [DealerClassification_Notes]) )
	AND ( [DealerClassification_Search] like ISNULL(@DealerClassification_Search, [DealerClassification_Search]) )
	AND ( [DealerClassification_TimeStamp] = ISNULL(@DealerClassification_TimeStamp, [DealerClassification_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersTypes-Insert]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	Insert record into table [dbo].[DealersTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersTypes-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersTypes-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersTypes-Insert]
	/*@DealerType_RowNumber int =Null OUTPUT , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerType_Code varchar(50) =Null  , 
	@DealerType_NameAr varchar(300) =Null  , 
	@DealerType_NameEn varchar(300) =Null  , 
	@DealerType_Notes varchar(max) =Null  , 
	@DealerType_Search varchar(max) =Null  , 
	@DealerType_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[DealersTypes](/*[DealerType_ID], [DealerType_Code], [DealerType_NameAr], [DealerType_NameEn], [DealerType_Notes], [DealerType_Search]*/)
	VALUES     (/*@DealerType_ID, @DealerType_Code, @DealerType_NameAr, @DealerType_NameEn, @DealerType_Notes, @DealerType_Search*/)

	/*SELECT @DealerType_RowNumber = [DealerType_RowNumber], @DealerType_TimeStamp = [DealerType_TimeStamp]
    FROM [dbo].[DealersTypes]
    WHERE  ( [DealerType_ID] =@DealerType_ID )
	AND  ( [DealerType_Code] =@DealerType_Code )
	AND  ( [DealerType_NameAr] =@DealerType_NameAr )
	AND  ( [DealerType_NameEn] =@DealerType_NameEn )
	AND  ( [DealerType_Notes] =@DealerType_Notes )
	AND  ( [DealerType_Search] =@DealerType_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersTypes-update]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	Update record in table [dbo].[DealersTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersTypes-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersTypes-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersTypes-update]
	/*@DealerType_RowNumber int =Null OUTPUT , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerType_Code varchar(50) =Null  , 
	@DealerType_NameAr varchar(300) =Null  , 
	@DealerType_NameEn varchar(300) =Null  , 
	@DealerType_Notes varchar(max) =Null  , 
	@DealerType_Search varchar(max) =Null  , 
	@DealerType_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [DealerType_TimeStamp]
    FROM [dbo].[DealersTypes]
    	WHERE ([DealerType_ID] = @DealerType_ID)

    IF  @OldTimeStamp = @DealerType_TimeStamp
    BEGIN*/
		Update [dbo].[DealersTypes] SET 
		/*[DealerType_ID] =@DealerType_ID, 
		[DealerType_Code] =@DealerType_Code, 
		[DealerType_NameAr] =@DealerType_NameAr, 
		[DealerType_NameEn] =@DealerType_NameEn, 
		[DealerType_Notes] =@DealerType_Notes, 
		[DealerType_Search] =@DealerType_Search*/
		/*WHERE ([DealerType_ID] = @DealerType_ID)*/
	/*END*/

	/*SELECT @DealerType_RowNumber = [DealerType_RowNumber], @DealerType_TimeStamp = [DealerType_TimeStamp]
    FROM [dbo].[DealersTypes]
	WHERE ([DealerType_ID] = @DealerType_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersTypes-Insert-Update]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	Insert OR Update record into table [dbo].[DealersTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersTypes-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersTypes-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersTypes-Insert-Update]
	/*@DealerType_RowNumber int =Null OUTPUT , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerType_Code varchar(50) =Null  , 
	@DealerType_NameAr varchar(300) =Null  , 
	@DealerType_NameEn varchar(300) =Null  , 
	@DealerType_Notes varchar(max) =Null  , 
	@DealerType_Search varchar(max) =Null  , 
	@DealerType_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[DealersTypes] 
					/*WHERE ([DealerType_ID] = @DealerType_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[DealersTypes](/*[DealerType_ID], [DealerType_Code], [DealerType_NameAr], [DealerType_NameEn], [DealerType_Notes], [DealerType_Search]*/)
		VALUES     (/*@DealerType_ID, @DealerType_Code, @DealerType_NameAr, @DealerType_NameEn, @DealerType_Notes, @DealerType_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [DealerType_TimeStamp]
		FROM [dbo].[DealersTypes]
    	WHERE ([DealerType_ID] = @DealerType_ID)

		IF  @OldTimeStamp = @DealerType_TimeStamp
		BEGIN*/
			Update [dbo].[DealersTypes] SET 
			/*[DealerType_ID] =@DealerType_ID, 
			[DealerType_Code] =@DealerType_Code, 
			[DealerType_NameAr] =@DealerType_NameAr, 
			[DealerType_NameEn] =@DealerType_NameEn, 
			[DealerType_Notes] =@DealerType_Notes, 
			[DealerType_Search] =@DealerType_Search*/
			/*WHERE ([DealerType_ID] = @DealerType_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @DealerType_RowNumber = [DealerType_RowNumber], @DealerType_TimeStamp = [DealerType_TimeStamp]
    FROM [dbo].[DealersTypes]
	WHERE ([DealerType_ID] = @DealerType_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersTypes-Delete]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	delete records from table [dbo].[DealersTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersTypes-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersTypes-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersTypes-Delete]
	/*@DealerType_RowNumber int =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerType_Code varchar(50) =null  , 
	@DealerType_NameAr varchar(300) =null  , 
	@DealerType_NameEn varchar(300) =null  , 
	@DealerType_Notes varchar(max) =null  , 
	@DealerType_Search varchar(max) =null  , 
	@DealerType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[DealersTypes]
	WHERE /*( [DealerType_RowNumber] = ISNULL(@DealerType_RowNumber, [DealerType_RowNumber]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerType_Code] like ISNULL(@DealerType_Code, [DealerType_Code]) )
	AND ( [DealerType_NameAr] like ISNULL(@DealerType_NameAr, [DealerType_NameAr]) )
	AND ( [DealerType_NameEn] like ISNULL(@DealerType_NameEn, [DealerType_NameEn]) )
	AND ( [DealerType_Notes] like ISNULL(@DealerType_Notes, [DealerType_Notes]) )
	AND ( [DealerType_Search] like ISNULL(@DealerType_Search, [DealerType_Search]) )
	AND ( [DealerType_TimeStamp] = ISNULL(@DealerType_TimeStamp, [DealerType_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersTypes-Select]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	select records from table [dbo].[DealersTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersTypes-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersTypes-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersTypes-Select]
	/*@DealerType_RowNumber int =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerType_Code varchar(50) =null  , 
	@DealerType_NameAr varchar(300) =null  , 
	@DealerType_NameEn varchar(300) =null  , 
	@DealerType_Notes varchar(max) =null  , 
	@DealerType_Search varchar(max) =null  , 
	@DealerType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[DealersTypes]
	WHERE /*( [DealerType_RowNumber] = ISNULL(@DealerType_RowNumber, [DealerType_RowNumber]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerType_Code] like ISNULL(@DealerType_Code, [DealerType_Code]) )
	AND ( [DealerType_NameAr] like ISNULL(@DealerType_NameAr, [DealerType_NameAr]) )
	AND ( [DealerType_NameEn] like ISNULL(@DealerType_NameEn, [DealerType_NameEn]) )
	AND ( [DealerType_Notes] like ISNULL(@DealerType_Notes, [DealerType_Notes]) )
	AND ( [DealerType_Search] like ISNULL(@DealerType_Search, [DealerType_Search]) )
	AND ( [DealerType_TimeStamp] = ISNULL(@DealerType_TimeStamp, [DealerType_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups-Insert]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	Insert record into table [dbo].[Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Insert]
	/*@Group_RowNumber int =Null OUTPUT , 
	@Group_ID uniqueidentifier =Null  , 
	@Group_NameAr varchar(200) =Null  , 
	@Group_NameEn varchar(200) =Null  , 
	@Group_Search varchar(max) =Null  , 
	@Is_SystemGroup tinyint =0  , 
	@Group_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Groups](/*[Group_ID], [Group_NameAr], [Group_NameEn], [Group_Search], [Is_SystemGroup]*/)
	VALUES     (/*@Group_ID, @Group_NameAr, @Group_NameEn, @Group_Search, @Is_SystemGroup*/)

	/*SELECT @Group_RowNumber = [Group_RowNumber], @Group_TimeStamp = [Group_TimeStamp]
    FROM [dbo].[Groups]
    WHERE  ( [Group_ID] =@Group_ID )
	AND  ( [Group_NameAr] =@Group_NameAr )
	AND  ( [Group_NameEn] =@Group_NameEn )
	AND  ( [Group_Search] =@Group_Search )
	AND  ( [Is_SystemGroup] =@Is_SystemGroup )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups-update]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	Update record in table [dbo].[Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-update]
	/*@Group_RowNumber int =Null OUTPUT , 
	@Group_ID uniqueidentifier =Null  , 
	@Group_NameAr varchar(200) =Null  , 
	@Group_NameEn varchar(200) =Null  , 
	@Group_Search varchar(max) =Null  , 
	@Is_SystemGroup tinyint =0  , 
	@Group_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Group_TimeStamp]
    FROM [dbo].[Groups]
    	WHERE ([Group_ID] = @Group_ID)

    IF  @OldTimeStamp = @Group_TimeStamp
    BEGIN*/
		Update [dbo].[Groups] SET 
		/*[Group_ID] =@Group_ID, 
		[Group_NameAr] =@Group_NameAr, 
		[Group_NameEn] =@Group_NameEn, 
		[Group_Search] =@Group_Search, 
		[Is_SystemGroup] =@Is_SystemGroup*/
		/*WHERE ([Group_ID] = @Group_ID)*/
	/*END*/

	/*SELECT @Group_RowNumber = [Group_RowNumber], @Group_TimeStamp = [Group_TimeStamp]
    FROM [dbo].[Groups]
	WHERE ([Group_ID] = @Group_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups-Insert-Update]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	Insert OR Update record into table [dbo].[Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Insert-Update]
	/*@Group_RowNumber int =Null OUTPUT , 
	@Group_ID uniqueidentifier =Null  , 
	@Group_NameAr varchar(200) =Null  , 
	@Group_NameEn varchar(200) =Null  , 
	@Group_Search varchar(max) =Null  , 
	@Is_SystemGroup tinyint =0  , 
	@Group_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Groups] 
					/*WHERE ([Group_ID] = @Group_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Groups](/*[Group_ID], [Group_NameAr], [Group_NameEn], [Group_Search], [Is_SystemGroup]*/)
		VALUES     (/*@Group_ID, @Group_NameAr, @Group_NameEn, @Group_Search, @Is_SystemGroup*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Group_TimeStamp]
		FROM [dbo].[Groups]
    	WHERE ([Group_ID] = @Group_ID)

		IF  @OldTimeStamp = @Group_TimeStamp
		BEGIN*/
			Update [dbo].[Groups] SET 
			/*[Group_ID] =@Group_ID, 
			[Group_NameAr] =@Group_NameAr, 
			[Group_NameEn] =@Group_NameEn, 
			[Group_Search] =@Group_Search, 
			[Is_SystemGroup] =@Is_SystemGroup*/
			/*WHERE ([Group_ID] = @Group_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Group_RowNumber = [Group_RowNumber], @Group_TimeStamp = [Group_TimeStamp]
    FROM [dbo].[Groups]
	WHERE ([Group_ID] = @Group_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups-Delete]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	delete records from table [dbo].[Groups] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Delete]
	/*@Group_RowNumber int =null  , 
	@Group_ID uniqueidentifier =null  , 
	@Group_NameAr varchar(200) =null  , 
	@Group_NameEn varchar(200) =null  , 
	@Group_Search varchar(max) =null  , 
	@Is_SystemGroup tinyint =null  , 
	@Group_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Groups]
	WHERE /*( [Group_RowNumber] = ISNULL(@Group_RowNumber, [Group_RowNumber]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [Group_NameAr] like ISNULL(@Group_NameAr, [Group_NameAr]) )
	AND ( [Group_NameEn] like ISNULL(@Group_NameEn, [Group_NameEn]) )
	AND ( [Group_Search] like ISNULL(@Group_Search, [Group_Search]) )
	AND ( [Is_SystemGroup] = ISNULL(@Is_SystemGroup, [Is_SystemGroup]) )
	AND ( [Group_TimeStamp] = ISNULL(@Group_TimeStamp, [Group_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups-Select]    Script Date: [[20120914064954]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064954]]
-- Description:	select records from table [dbo].[Groups] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups-Select]
	/*@Group_RowNumber int =null  , 
	@Group_ID uniqueidentifier =null  , 
	@Group_NameAr varchar(200) =null  , 
	@Group_NameEn varchar(200) =null  , 
	@Group_Search varchar(max) =null  , 
	@Is_SystemGroup tinyint =null  , 
	@Group_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Groups]
	WHERE /*( [Group_RowNumber] = ISNULL(@Group_RowNumber, [Group_RowNumber]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [Group_NameAr] like ISNULL(@Group_NameAr, [Group_NameAr]) )
	AND ( [Group_NameEn] like ISNULL(@Group_NameEn, [Group_NameEn]) )
	AND ( [Group_Search] like ISNULL(@Group_Search, [Group_Search]) )
	AND ( [Is_SystemGroup] = ISNULL(@Is_SystemGroup, [Is_SystemGroup]) )
	AND ( [Group_TimeStamp] = ISNULL(@Group_TimeStamp, [Group_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups_Permissions-Insert]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	Insert record into table [dbo].[Groups_Permissions]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups_Permissions-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups_Permissions-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups_Permissions-Insert]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Group_ID uniqueidentifier =Null  , 
	@Permission_ID uniqueidentifier =Null  , 
	@Group_Permission_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Groups_Permissions](/*[ID], [Group_ID], [Permission_ID]*/)
	VALUES     (/*@ID, @Group_ID, @Permission_ID*/)

	/*SELECT @RowNumber = [RowNumber], @Group_Permission_TimeStamp = [Group_Permission_TimeStamp]
    FROM [dbo].[Groups_Permissions]
    WHERE  ( [ID] =@ID )
	AND  ( [Group_ID] =@Group_ID )
	AND  ( [Permission_ID] =@Permission_ID )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups_Permissions-update]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	Update record in table [dbo].[Groups_Permissions]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups_Permissions-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups_Permissions-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups_Permissions-update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Group_ID uniqueidentifier =Null  , 
	@Permission_ID uniqueidentifier =Null  , 
	@Group_Permission_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Group_Permission_TimeStamp]
    FROM [dbo].[Groups_Permissions]
    	WHERE ([ID] = @ID)

    IF  @OldTimeStamp = @Group_Permission_TimeStamp
    BEGIN*/
		Update [dbo].[Groups_Permissions] SET 
		/*[ID] =@ID, 
		[Group_ID] =@Group_ID, 
		[Permission_ID] =@Permission_ID*/
		/*WHERE ([ID] = @ID)*/
	/*END*/

	/*SELECT @RowNumber = [RowNumber], @Group_Permission_TimeStamp = [Group_Permission_TimeStamp]
    FROM [dbo].[Groups_Permissions]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups_Permissions-Insert-Update]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	Insert OR Update record into table [dbo].[Groups_Permissions]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups_Permissions-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups_Permissions-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups_Permissions-Insert-Update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@Group_ID uniqueidentifier =Null  , 
	@Permission_ID uniqueidentifier =Null  , 
	@Group_Permission_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Groups_Permissions] 
					/*WHERE ([ID] = @ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Groups_Permissions](/*[ID], [Group_ID], [Permission_ID]*/)
		VALUES     (/*@ID, @Group_ID, @Permission_ID*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Group_Permission_TimeStamp]
		FROM [dbo].[Groups_Permissions]
    	WHERE ([ID] = @ID)

		IF  @OldTimeStamp = @Group_Permission_TimeStamp
		BEGIN*/
			Update [dbo].[Groups_Permissions] SET 
			/*[ID] =@ID, 
			[Group_ID] =@Group_ID, 
			[Permission_ID] =@Permission_ID*/
			/*WHERE ([ID] = @ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @RowNumber = [RowNumber], @Group_Permission_TimeStamp = [Group_Permission_TimeStamp]
    FROM [dbo].[Groups_Permissions]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups_Permissions-Delete]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	delete records from table [dbo].[Groups_Permissions] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups_Permissions-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups_Permissions-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups_Permissions-Delete]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@Group_ID uniqueidentifier =null  , 
	@Permission_ID uniqueidentifier =null  , 
	@Group_Permission_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Groups_Permissions]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [Permission_ID] = ISNULL(@Permission_ID, [Permission_ID]) )
	AND ( [Group_Permission_TimeStamp] = ISNULL(@Group_Permission_TimeStamp, [Group_Permission_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Groups_Permissions-Select]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	select records from table [dbo].[Groups_Permissions] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Groups_Permissions-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Groups_Permissions-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Groups_Permissions-Select]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@Group_ID uniqueidentifier =null  , 
	@Permission_ID uniqueidentifier =null  , 
	@Group_Permission_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Groups_Permissions]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [Permission_ID] = ISNULL(@Permission_ID, [Permission_ID]) )
	AND ( [Group_Permission_TimeStamp] = ISNULL(@Group_Permission_TimeStamp, [Group_Permission_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Images-Insert]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	Insert record into table [dbo].[Images]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Images-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Images-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Images-Insert]
	/*@Image_ID uniqueidentifier =Null  , 
	@Image_Default varbinary =Null  , 
	@Image_Data varbinary =Null  , 
	@Image_Description varchar(100) =Null  , 
	@Image_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Images](/*[Image_ID], [Image_Default], [Image_Data], [Image_Description]*/)
	VALUES     (/*@Image_ID, @Image_Default, @Image_Data, @Image_Description*/)

	/*SELECT @Image_TimeStamp = [Image_TimeStamp]
    FROM [dbo].[Images]
    WHERE  ( [Image_ID] =@Image_ID )
	AND  ( [Image_Default] =@Image_Default )
	AND  ( [Image_Data] =@Image_Data )
	AND  ( [Image_Description] =@Image_Description )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Images-update]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	Update record in table [dbo].[Images]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Images-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Images-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Images-update]
	/*@Image_ID uniqueidentifier =Null  , 
	@Image_Default varbinary =Null  , 
	@Image_Data varbinary =Null  , 
	@Image_Description varchar(100) =Null  , 
	@Image_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Image_TimeStamp]
    FROM [dbo].[Images]
    	WHERE ([Image_ID] = @Image_ID)

    IF  @OldTimeStamp = @Image_TimeStamp
    BEGIN*/
		Update [dbo].[Images] SET 
		/*[Image_ID] =@Image_ID, 
		[Image_Default] =@Image_Default, 
		[Image_Data] =@Image_Data, 
		[Image_Description] =@Image_Description*/
		/*WHERE ([Image_ID] = @Image_ID)*/
	/*END*/

	/*SELECT @Image_TimeStamp = [Image_TimeStamp]
    FROM [dbo].[Images]
	WHERE ([Image_ID] = @Image_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Images-Insert-Update]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	Insert OR Update record into table [dbo].[Images]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Images-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Images-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Images-Insert-Update]
	/*@Image_ID uniqueidentifier =Null  , 
	@Image_Default varbinary =Null  , 
	@Image_Data varbinary =Null  , 
	@Image_Description varchar(100) =Null  , 
	@Image_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Images] 
					/*WHERE ([Image_ID] = @Image_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Images](/*[Image_ID], [Image_Default], [Image_Data], [Image_Description]*/)
		VALUES     (/*@Image_ID, @Image_Default, @Image_Data, @Image_Description*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Image_TimeStamp]
		FROM [dbo].[Images]
    	WHERE ([Image_ID] = @Image_ID)

		IF  @OldTimeStamp = @Image_TimeStamp
		BEGIN*/
			Update [dbo].[Images] SET 
			/*[Image_ID] =@Image_ID, 
			[Image_Default] =@Image_Default, 
			[Image_Data] =@Image_Data, 
			[Image_Description] =@Image_Description*/
			/*WHERE ([Image_ID] = @Image_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Image_TimeStamp = [Image_TimeStamp]
    FROM [dbo].[Images]
	WHERE ([Image_ID] = @Image_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Images-Delete]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	delete records from table [dbo].[Images] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Images-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Images-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Images-Delete]
	/*@Image_ID uniqueidentifier =null  , 
	@Image_Default varbinary =null  , 
	@Image_Data varbinary =null  , 
	@Image_Description varchar(100) =null  , 
	@Image_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Images]
	WHERE /*( [Image_ID] = ISNULL(@Image_ID, [Image_ID]) )
	AND ( [Image_Default] = ISNULL(@Image_Default, [Image_Default]) )
	AND ( [Image_Data] = ISNULL(@Image_Data, [Image_Data]) )
	AND ( [Image_Description] like ISNULL(@Image_Description, [Image_Description]) )
	AND ( [Image_TimeStamp] = ISNULL(@Image_TimeStamp, [Image_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Images-Select]    Script Date: [[20120914064955]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064955]]
-- Description:	select records from table [dbo].[Images] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Images-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Images-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Images-Select]
	/*@Image_ID uniqueidentifier =null  , 
	@Image_Default varbinary =null  , 
	@Image_Data varbinary =null  , 
	@Image_Description varchar(100) =null  , 
	@Image_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Images]
	WHERE /*( [Image_ID] = ISNULL(@Image_ID, [Image_ID]) )
	AND ( [Image_Default] = ISNULL(@Image_Default, [Image_Default]) )
	AND ( [Image_Data] = ISNULL(@Image_Data, [Image_Data]) )
	AND ( [Image_Description] like ISNULL(@Image_Description, [Image_Description]) )
	AND ( [Image_TimeStamp] = ISNULL(@Image_TimeStamp, [Image_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Insert]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Insert record into table [dbo].[Importance]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Insert]
	/*@Importance_RowNumber int =Null OUTPUT , 
	@Importance_ID uniqueidentifier =Null  , 
	@Importance_Code varchar(50) =Null  , 
	@Importance_NameAr varchar(300) =Null  , 
	@Importance_NameEn varchar(300) =Null  , 
	@Importance_Notes varchar(max) =Null  , 
	@Importance_Search varchar(max) =Null  , 
	@Importance_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Importance](/*[Importance_ID], [Importance_Code], [Importance_NameAr], [Importance_NameEn], [Importance_Notes], [Importance_Search]*/)
	VALUES     (/*@Importance_ID, @Importance_Code, @Importance_NameAr, @Importance_NameEn, @Importance_Notes, @Importance_Search*/)

	/*SELECT @Importance_RowNumber = [Importance_RowNumber], @Importance_TimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
    WHERE  ( [Importance_ID] =@Importance_ID )
	AND  ( [Importance_Code] =@Importance_Code )
	AND  ( [Importance_NameAr] =@Importance_NameAr )
	AND  ( [Importance_NameEn] =@Importance_NameEn )
	AND  ( [Importance_Notes] =@Importance_Notes )
	AND  ( [Importance_Search] =@Importance_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-update]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Update record in table [dbo].[Importance]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-update]
	/*@Importance_RowNumber int =Null OUTPUT , 
	@Importance_ID uniqueidentifier =Null  , 
	@Importance_Code varchar(50) =Null  , 
	@Importance_NameAr varchar(300) =Null  , 
	@Importance_NameEn varchar(300) =Null  , 
	@Importance_Notes varchar(max) =Null  , 
	@Importance_Search varchar(max) =Null  , 
	@Importance_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
    	WHERE ([Importance_ID] = @Importance_ID)

    IF  @OldTimeStamp = @Importance_TimeStamp
    BEGIN*/
		Update [dbo].[Importance] SET 
		/*[Importance_ID] =@Importance_ID, 
		[Importance_Code] =@Importance_Code, 
		[Importance_NameAr] =@Importance_NameAr, 
		[Importance_NameEn] =@Importance_NameEn, 
		[Importance_Notes] =@Importance_Notes, 
		[Importance_Search] =@Importance_Search*/
		/*WHERE ([Importance_ID] = @Importance_ID)*/
	/*END*/

	/*SELECT @Importance_RowNumber = [Importance_RowNumber], @Importance_TimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
	WHERE ([Importance_ID] = @Importance_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Insert-Update]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Insert OR Update record into table [dbo].[Importance]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Insert-Update]
	/*@Importance_RowNumber int =Null OUTPUT , 
	@Importance_ID uniqueidentifier =Null  , 
	@Importance_Code varchar(50) =Null  , 
	@Importance_NameAr varchar(300) =Null  , 
	@Importance_NameEn varchar(300) =Null  , 
	@Importance_Notes varchar(max) =Null  , 
	@Importance_Search varchar(max) =Null  , 
	@Importance_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Importance] 
					/*WHERE ([Importance_ID] = @Importance_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Importance](/*[Importance_ID], [Importance_Code], [Importance_NameAr], [Importance_NameEn], [Importance_Notes], [Importance_Search]*/)
		VALUES     (/*@Importance_ID, @Importance_Code, @Importance_NameAr, @Importance_NameEn, @Importance_Notes, @Importance_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Importance_TimeStamp]
		FROM [dbo].[Importance]
    	WHERE ([Importance_ID] = @Importance_ID)

		IF  @OldTimeStamp = @Importance_TimeStamp
		BEGIN*/
			Update [dbo].[Importance] SET 
			/*[Importance_ID] =@Importance_ID, 
			[Importance_Code] =@Importance_Code, 
			[Importance_NameAr] =@Importance_NameAr, 
			[Importance_NameEn] =@Importance_NameEn, 
			[Importance_Notes] =@Importance_Notes, 
			[Importance_Search] =@Importance_Search*/
			/*WHERE ([Importance_ID] = @Importance_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Importance_RowNumber = [Importance_RowNumber], @Importance_TimeStamp = [Importance_TimeStamp]
    FROM [dbo].[Importance]
	WHERE ([Importance_ID] = @Importance_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Delete]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	delete records from table [dbo].[Importance] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Delete]
	/*@Importance_RowNumber int =null  , 
	@Importance_ID uniqueidentifier =null  , 
	@Importance_Code varchar(50) =null  , 
	@Importance_NameAr varchar(300) =null  , 
	@Importance_NameEn varchar(300) =null  , 
	@Importance_Notes varchar(max) =null  , 
	@Importance_Search varchar(max) =null  , 
	@Importance_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Importance]
	WHERE /*( [Importance_RowNumber] = ISNULL(@Importance_RowNumber, [Importance_RowNumber]) )
	AND ( [Importance_ID] = ISNULL(@Importance_ID, [Importance_ID]) )
	AND ( [Importance_Code] like ISNULL(@Importance_Code, [Importance_Code]) )
	AND ( [Importance_NameAr] like ISNULL(@Importance_NameAr, [Importance_NameAr]) )
	AND ( [Importance_NameEn] like ISNULL(@Importance_NameEn, [Importance_NameEn]) )
	AND ( [Importance_Notes] like ISNULL(@Importance_Notes, [Importance_Notes]) )
	AND ( [Importance_Search] like ISNULL(@Importance_Search, [Importance_Search]) )
	AND ( [Importance_TimeStamp] = ISNULL(@Importance_TimeStamp, [Importance_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Importance-Select]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	select records from table [dbo].[Importance] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Importance-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Importance-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Importance-Select]
	/*@Importance_RowNumber int =null  , 
	@Importance_ID uniqueidentifier =null  , 
	@Importance_Code varchar(50) =null  , 
	@Importance_NameAr varchar(300) =null  , 
	@Importance_NameEn varchar(300) =null  , 
	@Importance_Notes varchar(max) =null  , 
	@Importance_Search varchar(max) =null  , 
	@Importance_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Importance]
	WHERE /*( [Importance_RowNumber] = ISNULL(@Importance_RowNumber, [Importance_RowNumber]) )
	AND ( [Importance_ID] = ISNULL(@Importance_ID, [Importance_ID]) )
	AND ( [Importance_Code] like ISNULL(@Importance_Code, [Importance_Code]) )
	AND ( [Importance_NameAr] like ISNULL(@Importance_NameAr, [Importance_NameAr]) )
	AND ( [Importance_NameEn] like ISNULL(@Importance_NameEn, [Importance_NameEn]) )
	AND ( [Importance_Notes] like ISNULL(@Importance_Notes, [Importance_Notes]) )
	AND ( [Importance_Search] like ISNULL(@Importance_Search, [Importance_Search]) )
	AND ( [Importance_TimeStamp] = ISNULL(@Importance_TimeStamp, [Importance_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Jobs-Insert]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Insert record into table [dbo].[Jobs]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Jobs-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Jobs-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Jobs-Insert]
	/*@Job_RowNumber int =Null OUTPUT , 
	@Job_ID uniqueidentifier =Null  , 
	@Job_Code varchar(50) =Null  , 
	@Job_NameAr varchar(300) =Null  , 
	@Job_NameEn varchar(300) =Null  , 
	@Job_Notes varchar(max) =Null  , 
	@Job_Search varchar(max) =Null  , 
	@Job_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Jobs](/*[Job_ID], [Job_Code], [Job_NameAr], [Job_NameEn], [Job_Notes], [Job_Search]*/)
	VALUES     (/*@Job_ID, @Job_Code, @Job_NameAr, @Job_NameEn, @Job_Notes, @Job_Search*/)

	/*SELECT @Job_RowNumber = [Job_RowNumber], @Job_TimeStamp = [Job_TimeStamp]
    FROM [dbo].[Jobs]
    WHERE  ( [Job_ID] =@Job_ID )
	AND  ( [Job_Code] =@Job_Code )
	AND  ( [Job_NameAr] =@Job_NameAr )
	AND  ( [Job_NameEn] =@Job_NameEn )
	AND  ( [Job_Notes] =@Job_Notes )
	AND  ( [Job_Search] =@Job_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Jobs-update]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Update record in table [dbo].[Jobs]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Jobs-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Jobs-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Jobs-update]
	/*@Job_RowNumber int =Null OUTPUT , 
	@Job_ID uniqueidentifier =Null  , 
	@Job_Code varchar(50) =Null  , 
	@Job_NameAr varchar(300) =Null  , 
	@Job_NameEn varchar(300) =Null  , 
	@Job_Notes varchar(max) =Null  , 
	@Job_Search varchar(max) =Null  , 
	@Job_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Job_TimeStamp]
    FROM [dbo].[Jobs]
    	WHERE ([Job_ID] = @Job_ID)

    IF  @OldTimeStamp = @Job_TimeStamp
    BEGIN*/
		Update [dbo].[Jobs] SET 
		/*[Job_ID] =@Job_ID, 
		[Job_Code] =@Job_Code, 
		[Job_NameAr] =@Job_NameAr, 
		[Job_NameEn] =@Job_NameEn, 
		[Job_Notes] =@Job_Notes, 
		[Job_Search] =@Job_Search*/
		/*WHERE ([Job_ID] = @Job_ID)*/
	/*END*/

	/*SELECT @Job_RowNumber = [Job_RowNumber], @Job_TimeStamp = [Job_TimeStamp]
    FROM [dbo].[Jobs]
	WHERE ([Job_ID] = @Job_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Jobs-Insert-Update]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	Insert OR Update record into table [dbo].[Jobs]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Jobs-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Jobs-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Jobs-Insert-Update]
	/*@Job_RowNumber int =Null OUTPUT , 
	@Job_ID uniqueidentifier =Null  , 
	@Job_Code varchar(50) =Null  , 
	@Job_NameAr varchar(300) =Null  , 
	@Job_NameEn varchar(300) =Null  , 
	@Job_Notes varchar(max) =Null  , 
	@Job_Search varchar(max) =Null  , 
	@Job_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Jobs] 
					/*WHERE ([Job_ID] = @Job_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Jobs](/*[Job_ID], [Job_Code], [Job_NameAr], [Job_NameEn], [Job_Notes], [Job_Search]*/)
		VALUES     (/*@Job_ID, @Job_Code, @Job_NameAr, @Job_NameEn, @Job_Notes, @Job_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Job_TimeStamp]
		FROM [dbo].[Jobs]
    	WHERE ([Job_ID] = @Job_ID)

		IF  @OldTimeStamp = @Job_TimeStamp
		BEGIN*/
			Update [dbo].[Jobs] SET 
			/*[Job_ID] =@Job_ID, 
			[Job_Code] =@Job_Code, 
			[Job_NameAr] =@Job_NameAr, 
			[Job_NameEn] =@Job_NameEn, 
			[Job_Notes] =@Job_Notes, 
			[Job_Search] =@Job_Search*/
			/*WHERE ([Job_ID] = @Job_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Job_RowNumber = [Job_RowNumber], @Job_TimeStamp = [Job_TimeStamp]
    FROM [dbo].[Jobs]
	WHERE ([Job_ID] = @Job_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Jobs-Delete]    Script Date: [[20120914064956]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064956]]
-- Description:	delete records from table [dbo].[Jobs] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Jobs-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Jobs-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Jobs-Delete]
	/*@Job_RowNumber int =null  , 
	@Job_ID uniqueidentifier =null  , 
	@Job_Code varchar(50) =null  , 
	@Job_NameAr varchar(300) =null  , 
	@Job_NameEn varchar(300) =null  , 
	@Job_Notes varchar(max) =null  , 
	@Job_Search varchar(max) =null  , 
	@Job_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Jobs]
	WHERE /*( [Job_RowNumber] = ISNULL(@Job_RowNumber, [Job_RowNumber]) )
	AND ( [Job_ID] = ISNULL(@Job_ID, [Job_ID]) )
	AND ( [Job_Code] like ISNULL(@Job_Code, [Job_Code]) )
	AND ( [Job_NameAr] like ISNULL(@Job_NameAr, [Job_NameAr]) )
	AND ( [Job_NameEn] like ISNULL(@Job_NameEn, [Job_NameEn]) )
	AND ( [Job_Notes] like ISNULL(@Job_Notes, [Job_Notes]) )
	AND ( [Job_Search] like ISNULL(@Job_Search, [Job_Search]) )
	AND ( [Job_TimeStamp] = ISNULL(@Job_TimeStamp, [Job_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Jobs-Select]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	select records from table [dbo].[Jobs] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Jobs-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Jobs-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Jobs-Select]
	/*@Job_RowNumber int =null  , 
	@Job_ID uniqueidentifier =null  , 
	@Job_Code varchar(50) =null  , 
	@Job_NameAr varchar(300) =null  , 
	@Job_NameEn varchar(300) =null  , 
	@Job_Notes varchar(max) =null  , 
	@Job_Search varchar(max) =null  , 
	@Job_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Jobs]
	WHERE /*( [Job_RowNumber] = ISNULL(@Job_RowNumber, [Job_RowNumber]) )
	AND ( [Job_ID] = ISNULL(@Job_ID, [Job_ID]) )
	AND ( [Job_Code] like ISNULL(@Job_Code, [Job_Code]) )
	AND ( [Job_NameAr] like ISNULL(@Job_NameAr, [Job_NameAr]) )
	AND ( [Job_NameEn] like ISNULL(@Job_NameEn, [Job_NameEn]) )
	AND ( [Job_Notes] like ISNULL(@Job_Notes, [Job_Notes]) )
	AND ( [Job_Search] like ISNULL(@Job_Search, [Job_Search]) )
	AND ( [Job_TimeStamp] = ISNULL(@Job_TimeStamp, [Job_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Insert]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Insert record into table [dbo].[MaritalStatus]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Insert]
	/*@MaritalStatus_RowNumber int =Null OUTPUT , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@MaritalStatus_Code varchar(50) =Null  , 
	@MaritalStatus_NameAr varchar(300) =Null  , 
	@MaritalStatus_NameEn varchar(300) =Null  , 
	@MaritalStatus_Notes varchar(max) =Null  , 
	@MaritalStatus_Search varchar(max) =Null  , 
	@MaritalStatus_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[MaritalStatus](/*[MaritalStatus_ID], [MaritalStatus_Code], [MaritalStatus_NameAr], [MaritalStatus_NameEn], [MaritalStatus_Notes], [MaritalStatus_Search]*/)
	VALUES     (/*@MaritalStatus_ID, @MaritalStatus_Code, @MaritalStatus_NameAr, @MaritalStatus_NameEn, @MaritalStatus_Notes, @MaritalStatus_Search*/)

	/*SELECT @MaritalStatus_RowNumber = [MaritalStatus_RowNumber], @MaritalStatus_TimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
    WHERE  ( [MaritalStatus_ID] =@MaritalStatus_ID )
	AND  ( [MaritalStatus_Code] =@MaritalStatus_Code )
	AND  ( [MaritalStatus_NameAr] =@MaritalStatus_NameAr )
	AND  ( [MaritalStatus_NameEn] =@MaritalStatus_NameEn )
	AND  ( [MaritalStatus_Notes] =@MaritalStatus_Notes )
	AND  ( [MaritalStatus_Search] =@MaritalStatus_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-update]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Update record in table [dbo].[MaritalStatus]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-update]
	/*@MaritalStatus_RowNumber int =Null OUTPUT , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@MaritalStatus_Code varchar(50) =Null  , 
	@MaritalStatus_NameAr varchar(300) =Null  , 
	@MaritalStatus_NameEn varchar(300) =Null  , 
	@MaritalStatus_Notes varchar(max) =Null  , 
	@MaritalStatus_Search varchar(max) =Null  , 
	@MaritalStatus_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
    	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)

    IF  @OldTimeStamp = @MaritalStatus_TimeStamp
    BEGIN*/
		Update [dbo].[MaritalStatus] SET 
		/*[MaritalStatus_ID] =@MaritalStatus_ID, 
		[MaritalStatus_Code] =@MaritalStatus_Code, 
		[MaritalStatus_NameAr] =@MaritalStatus_NameAr, 
		[MaritalStatus_NameEn] =@MaritalStatus_NameEn, 
		[MaritalStatus_Notes] =@MaritalStatus_Notes, 
		[MaritalStatus_Search] =@MaritalStatus_Search*/
		/*WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
	/*END*/

	/*SELECT @MaritalStatus_RowNumber = [MaritalStatus_RowNumber], @MaritalStatus_TimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Insert-Update]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Insert OR Update record into table [dbo].[MaritalStatus]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Insert-Update]
	/*@MaritalStatus_RowNumber int =Null OUTPUT , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@MaritalStatus_Code varchar(50) =Null  , 
	@MaritalStatus_NameAr varchar(300) =Null  , 
	@MaritalStatus_NameEn varchar(300) =Null  , 
	@MaritalStatus_Notes varchar(max) =Null  , 
	@MaritalStatus_Search varchar(max) =Null  , 
	@MaritalStatus_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[MaritalStatus] 
					/*WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[MaritalStatus](/*[MaritalStatus_ID], [MaritalStatus_Code], [MaritalStatus_NameAr], [MaritalStatus_NameEn], [MaritalStatus_Notes], [MaritalStatus_Search]*/)
		VALUES     (/*@MaritalStatus_ID, @MaritalStatus_Code, @MaritalStatus_NameAr, @MaritalStatus_NameEn, @MaritalStatus_Notes, @MaritalStatus_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [MaritalStatus_TimeStamp]
		FROM [dbo].[MaritalStatus]
    	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)

		IF  @OldTimeStamp = @MaritalStatus_TimeStamp
		BEGIN*/
			Update [dbo].[MaritalStatus] SET 
			/*[MaritalStatus_ID] =@MaritalStatus_ID, 
			[MaritalStatus_Code] =@MaritalStatus_Code, 
			[MaritalStatus_NameAr] =@MaritalStatus_NameAr, 
			[MaritalStatus_NameEn] =@MaritalStatus_NameEn, 
			[MaritalStatus_Notes] =@MaritalStatus_Notes, 
			[MaritalStatus_Search] =@MaritalStatus_Search*/
			/*WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @MaritalStatus_RowNumber = [MaritalStatus_RowNumber], @MaritalStatus_TimeStamp = [MaritalStatus_TimeStamp]
    FROM [dbo].[MaritalStatus]
	WHERE ([MaritalStatus_ID] = @MaritalStatus_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Delete]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	delete records from table [dbo].[MaritalStatus] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Delete]
	/*@MaritalStatus_RowNumber int =null  , 
	@MaritalStatus_ID uniqueidentifier =null  , 
	@MaritalStatus_Code varchar(50) =null  , 
	@MaritalStatus_NameAr varchar(300) =null  , 
	@MaritalStatus_NameEn varchar(300) =null  , 
	@MaritalStatus_Notes varchar(max) =null  , 
	@MaritalStatus_Search varchar(max) =null  , 
	@MaritalStatus_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[MaritalStatus]
	WHERE /*( [MaritalStatus_RowNumber] = ISNULL(@MaritalStatus_RowNumber, [MaritalStatus_RowNumber]) )
	AND ( [MaritalStatus_ID] = ISNULL(@MaritalStatus_ID, [MaritalStatus_ID]) )
	AND ( [MaritalStatus_Code] like ISNULL(@MaritalStatus_Code, [MaritalStatus_Code]) )
	AND ( [MaritalStatus_NameAr] like ISNULL(@MaritalStatus_NameAr, [MaritalStatus_NameAr]) )
	AND ( [MaritalStatus_NameEn] like ISNULL(@MaritalStatus_NameEn, [MaritalStatus_NameEn]) )
	AND ( [MaritalStatus_Notes] like ISNULL(@MaritalStatus_Notes, [MaritalStatus_Notes]) )
	AND ( [MaritalStatus_Search] like ISNULL(@MaritalStatus_Search, [MaritalStatus_Search]) )
	AND ( [MaritalStatus_TimeStamp] = ISNULL(@MaritalStatus_TimeStamp, [MaritalStatus_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MaritalStatus-Select]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	select records from table [dbo].[MaritalStatus] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MaritalStatus-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MaritalStatus-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MaritalStatus-Select]
	/*@MaritalStatus_RowNumber int =null  , 
	@MaritalStatus_ID uniqueidentifier =null  , 
	@MaritalStatus_Code varchar(50) =null  , 
	@MaritalStatus_NameAr varchar(300) =null  , 
	@MaritalStatus_NameEn varchar(300) =null  , 
	@MaritalStatus_Notes varchar(max) =null  , 
	@MaritalStatus_Search varchar(max) =null  , 
	@MaritalStatus_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[MaritalStatus]
	WHERE /*( [MaritalStatus_RowNumber] = ISNULL(@MaritalStatus_RowNumber, [MaritalStatus_RowNumber]) )
	AND ( [MaritalStatus_ID] = ISNULL(@MaritalStatus_ID, [MaritalStatus_ID]) )
	AND ( [MaritalStatus_Code] like ISNULL(@MaritalStatus_Code, [MaritalStatus_Code]) )
	AND ( [MaritalStatus_NameAr] like ISNULL(@MaritalStatus_NameAr, [MaritalStatus_NameAr]) )
	AND ( [MaritalStatus_NameEn] like ISNULL(@MaritalStatus_NameEn, [MaritalStatus_NameEn]) )
	AND ( [MaritalStatus_Notes] like ISNULL(@MaritalStatus_Notes, [MaritalStatus_Notes]) )
	AND ( [MaritalStatus_Search] like ISNULL(@MaritalStatus_Search, [MaritalStatus_Search]) )
	AND ( [MaritalStatus_TimeStamp] = ISNULL(@MaritalStatus_TimeStamp, [MaritalStatus_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Insert]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Insert record into table [dbo].[MimeTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Insert]
	/*@Mime_RowNumber int =Null OUTPUT , 
	@Mime_ID uniqueidentifier =Null  , 
	@Mime_NameAr varchar(300) =Null  , 
	@Mime_NameEn varchar(300) =Null  , 
	@Mime_Notes varchar(max) =Null  , 
	@Mime_Search varchar(max) =Null  , 
	@MimeType_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[MimeTypes](/*[Mime_ID], [Mime_NameAr], [Mime_NameEn], [Mime_Notes], [Mime_Search]*/)
	VALUES     (/*@Mime_ID, @Mime_NameAr, @Mime_NameEn, @Mime_Notes, @Mime_Search*/)

	/*SELECT @Mime_RowNumber = [Mime_RowNumber], @MimeType_TimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
    WHERE  ( [Mime_ID] =@Mime_ID )
	AND  ( [Mime_NameAr] =@Mime_NameAr )
	AND  ( [Mime_NameEn] =@Mime_NameEn )
	AND  ( [Mime_Notes] =@Mime_Notes )
	AND  ( [Mime_Search] =@Mime_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-update]    Script Date: [[20120914064957]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064957]]
-- Description:	Update record in table [dbo].[MimeTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-update]
	/*@Mime_RowNumber int =Null OUTPUT , 
	@Mime_ID uniqueidentifier =Null  , 
	@Mime_NameAr varchar(300) =Null  , 
	@Mime_NameEn varchar(300) =Null  , 
	@Mime_Notes varchar(max) =Null  , 
	@Mime_Search varchar(max) =Null  , 
	@MimeType_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
    	WHERE ([Mime_ID] = @Mime_ID)

    IF  @OldTimeStamp = @MimeType_TimeStamp
    BEGIN*/
		Update [dbo].[MimeTypes] SET 
		/*[Mime_ID] =@Mime_ID, 
		[Mime_NameAr] =@Mime_NameAr, 
		[Mime_NameEn] =@Mime_NameEn, 
		[Mime_Notes] =@Mime_Notes, 
		[Mime_Search] =@Mime_Search*/
		/*WHERE ([Mime_ID] = @Mime_ID)*/
	/*END*/

	/*SELECT @Mime_RowNumber = [Mime_RowNumber], @MimeType_TimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
	WHERE ([Mime_ID] = @Mime_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Insert-Update]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	Insert OR Update record into table [dbo].[MimeTypes]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Insert-Update]
	/*@Mime_RowNumber int =Null OUTPUT , 
	@Mime_ID uniqueidentifier =Null  , 
	@Mime_NameAr varchar(300) =Null  , 
	@Mime_NameEn varchar(300) =Null  , 
	@Mime_Notes varchar(max) =Null  , 
	@Mime_Search varchar(max) =Null  , 
	@MimeType_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[MimeTypes] 
					/*WHERE ([Mime_ID] = @Mime_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[MimeTypes](/*[Mime_ID], [Mime_NameAr], [Mime_NameEn], [Mime_Notes], [Mime_Search]*/)
		VALUES     (/*@Mime_ID, @Mime_NameAr, @Mime_NameEn, @Mime_Notes, @Mime_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [MimeType_TimeStamp]
		FROM [dbo].[MimeTypes]
    	WHERE ([Mime_ID] = @Mime_ID)

		IF  @OldTimeStamp = @MimeType_TimeStamp
		BEGIN*/
			Update [dbo].[MimeTypes] SET 
			/*[Mime_ID] =@Mime_ID, 
			[Mime_NameAr] =@Mime_NameAr, 
			[Mime_NameEn] =@Mime_NameEn, 
			[Mime_Notes] =@Mime_Notes, 
			[Mime_Search] =@Mime_Search*/
			/*WHERE ([Mime_ID] = @Mime_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Mime_RowNumber = [Mime_RowNumber], @MimeType_TimeStamp = [MimeType_TimeStamp]
    FROM [dbo].[MimeTypes]
	WHERE ([Mime_ID] = @Mime_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Delete]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	delete records from table [dbo].[MimeTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Delete]
	/*@Mime_RowNumber int =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@Mime_NameAr varchar(300) =null  , 
	@Mime_NameEn varchar(300) =null  , 
	@Mime_Notes varchar(max) =null  , 
	@Mime_Search varchar(max) =null  , 
	@MimeType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[MimeTypes]
	WHERE /*( [Mime_RowNumber] = ISNULL(@Mime_RowNumber, [Mime_RowNumber]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [Mime_NameAr] like ISNULL(@Mime_NameAr, [Mime_NameAr]) )
	AND ( [Mime_NameEn] like ISNULL(@Mime_NameEn, [Mime_NameEn]) )
	AND ( [Mime_Notes] like ISNULL(@Mime_Notes, [Mime_Notes]) )
	AND ( [Mime_Search] like ISNULL(@Mime_Search, [Mime_Search]) )
	AND ( [MimeType_TimeStamp] = ISNULL(@MimeType_TimeStamp, [MimeType_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[MimeTypes-Select]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	select records from table [dbo].[MimeTypes] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[MimeTypes-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[MimeTypes-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[MimeTypes-Select]
	/*@Mime_RowNumber int =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@Mime_NameAr varchar(300) =null  , 
	@Mime_NameEn varchar(300) =null  , 
	@Mime_Notes varchar(max) =null  , 
	@Mime_Search varchar(max) =null  , 
	@MimeType_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[MimeTypes]
	WHERE /*( [Mime_RowNumber] = ISNULL(@Mime_RowNumber, [Mime_RowNumber]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [Mime_NameAr] like ISNULL(@Mime_NameAr, [Mime_NameAr]) )
	AND ( [Mime_NameEn] like ISNULL(@Mime_NameEn, [Mime_NameEn]) )
	AND ( [Mime_Notes] like ISNULL(@Mime_Notes, [Mime_Notes]) )
	AND ( [Mime_Search] like ISNULL(@Mime_Search, [Mime_Search]) )
	AND ( [MimeType_TimeStamp] = ISNULL(@MimeType_TimeStamp, [MimeType_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Permissions-Insert]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	Insert record into table [dbo].[Permissions]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Permissions-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Permissions-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Permissions-Insert]
	/*@Permission_RowNumber int =Null OUTPUT , 
	@Permission_ID uniqueidentifier =Null  , 
	@Permission_NameAr varchar(200) =Null  , 
	@Permission_NameEn varchar(200) =Null  , 
	@Permission_Search varchar(max) =Null  , 
	@Permission_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Permissions](/*[Permission_ID], [Permission_NameAr], [Permission_NameEn], [Permission_Search]*/)
	VALUES     (/*@Permission_ID, @Permission_NameAr, @Permission_NameEn, @Permission_Search*/)

	/*SELECT @Permission_RowNumber = [Permission_RowNumber], @Permission_TimeStamp = [Permission_TimeStamp]
    FROM [dbo].[Permissions]
    WHERE  ( [Permission_ID] =@Permission_ID )
	AND  ( [Permission_NameAr] =@Permission_NameAr )
	AND  ( [Permission_NameEn] =@Permission_NameEn )
	AND  ( [Permission_Search] =@Permission_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Permissions-update]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	Update record in table [dbo].[Permissions]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Permissions-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Permissions-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Permissions-update]
	/*@Permission_RowNumber int =Null OUTPUT , 
	@Permission_ID uniqueidentifier =Null  , 
	@Permission_NameAr varchar(200) =Null  , 
	@Permission_NameEn varchar(200) =Null  , 
	@Permission_Search varchar(max) =Null  , 
	@Permission_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Permission_TimeStamp]
    FROM [dbo].[Permissions]
    	WHERE ([Permission_ID] = @Permission_ID)

    IF  @OldTimeStamp = @Permission_TimeStamp
    BEGIN*/
		Update [dbo].[Permissions] SET 
		/*[Permission_ID] =@Permission_ID, 
		[Permission_NameAr] =@Permission_NameAr, 
		[Permission_NameEn] =@Permission_NameEn, 
		[Permission_Search] =@Permission_Search*/
		/*WHERE ([Permission_ID] = @Permission_ID)*/
	/*END*/

	/*SELECT @Permission_RowNumber = [Permission_RowNumber], @Permission_TimeStamp = [Permission_TimeStamp]
    FROM [dbo].[Permissions]
	WHERE ([Permission_ID] = @Permission_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Permissions-Insert-Update]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	Insert OR Update record into table [dbo].[Permissions]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Permissions-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Permissions-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Permissions-Insert-Update]
	/*@Permission_RowNumber int =Null OUTPUT , 
	@Permission_ID uniqueidentifier =Null  , 
	@Permission_NameAr varchar(200) =Null  , 
	@Permission_NameEn varchar(200) =Null  , 
	@Permission_Search varchar(max) =Null  , 
	@Permission_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Permissions] 
					/*WHERE ([Permission_ID] = @Permission_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Permissions](/*[Permission_ID], [Permission_NameAr], [Permission_NameEn], [Permission_Search]*/)
		VALUES     (/*@Permission_ID, @Permission_NameAr, @Permission_NameEn, @Permission_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Permission_TimeStamp]
		FROM [dbo].[Permissions]
    	WHERE ([Permission_ID] = @Permission_ID)

		IF  @OldTimeStamp = @Permission_TimeStamp
		BEGIN*/
			Update [dbo].[Permissions] SET 
			/*[Permission_ID] =@Permission_ID, 
			[Permission_NameAr] =@Permission_NameAr, 
			[Permission_NameEn] =@Permission_NameEn, 
			[Permission_Search] =@Permission_Search*/
			/*WHERE ([Permission_ID] = @Permission_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Permission_RowNumber = [Permission_RowNumber], @Permission_TimeStamp = [Permission_TimeStamp]
    FROM [dbo].[Permissions]
	WHERE ([Permission_ID] = @Permission_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Permissions-Delete]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	delete records from table [dbo].[Permissions] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Permissions-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Permissions-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Permissions-Delete]
	/*@Permission_RowNumber int =null  , 
	@Permission_ID uniqueidentifier =null  , 
	@Permission_NameAr varchar(200) =null  , 
	@Permission_NameEn varchar(200) =null  , 
	@Permission_Search varchar(max) =null  , 
	@Permission_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Permissions]
	WHERE /*( [Permission_RowNumber] = ISNULL(@Permission_RowNumber, [Permission_RowNumber]) )
	AND ( [Permission_ID] = ISNULL(@Permission_ID, [Permission_ID]) )
	AND ( [Permission_NameAr] like ISNULL(@Permission_NameAr, [Permission_NameAr]) )
	AND ( [Permission_NameEn] like ISNULL(@Permission_NameEn, [Permission_NameEn]) )
	AND ( [Permission_Search] like ISNULL(@Permission_Search, [Permission_Search]) )
	AND ( [Permission_TimeStamp] = ISNULL(@Permission_TimeStamp, [Permission_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Permissions-Select]    Script Date: [[20120914064958]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064958]]
-- Description:	select records from table [dbo].[Permissions] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Permissions-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Permissions-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Permissions-Select]
	/*@Permission_RowNumber int =null  , 
	@Permission_ID uniqueidentifier =null  , 
	@Permission_NameAr varchar(200) =null  , 
	@Permission_NameEn varchar(200) =null  , 
	@Permission_Search varchar(max) =null  , 
	@Permission_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Permissions]
	WHERE /*( [Permission_RowNumber] = ISNULL(@Permission_RowNumber, [Permission_RowNumber]) )
	AND ( [Permission_ID] = ISNULL(@Permission_ID, [Permission_ID]) )
	AND ( [Permission_NameAr] like ISNULL(@Permission_NameAr, [Permission_NameAr]) )
	AND ( [Permission_NameEn] like ISNULL(@Permission_NameEn, [Permission_NameEn]) )
	AND ( [Permission_Search] like ISNULL(@Permission_Search, [Permission_Search]) )
	AND ( [Permission_TimeStamp] = ISNULL(@Permission_TimeStamp, [Permission_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Persons-Insert]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	Insert record into table [dbo].[Persons]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Persons-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Persons-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Persons-Insert]
	/*@Person_RowNumber int =Null OUTPUT , 
	@Person_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Person_Code varchar(50) =Null  , 
	@Person_NameAr varchar(300) =Null  , 
	@Person_NameEn varchar(300) =Null  , 
	@Person_Notes varchar(max) =Null  , 
	@Person_Search varchar(max) =Null  , 
	@Person_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Persons](/*[Person_ID], [Dealer_ID], [Person_Code], [Person_NameAr], [Person_NameEn], [Person_Notes], [Person_Search]*/)
	VALUES     (/*@Person_ID, @Dealer_ID, @Person_Code, @Person_NameAr, @Person_NameEn, @Person_Notes, @Person_Search*/)

	/*SELECT @Person_RowNumber = [Person_RowNumber], @Person_TimeStamp = [Person_TimeStamp]
    FROM [dbo].[Persons]
    WHERE  ( [Person_ID] =@Person_ID )
	AND  ( [Dealer_ID] =@Dealer_ID )
	AND  ( [Person_Code] =@Person_Code )
	AND  ( [Person_NameAr] =@Person_NameAr )
	AND  ( [Person_NameEn] =@Person_NameEn )
	AND  ( [Person_Notes] =@Person_Notes )
	AND  ( [Person_Search] =@Person_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Persons-update]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	Update record in table [dbo].[Persons]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Persons-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Persons-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Persons-update]
	/*@Person_RowNumber int =Null OUTPUT , 
	@Person_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Person_Code varchar(50) =Null  , 
	@Person_NameAr varchar(300) =Null  , 
	@Person_NameEn varchar(300) =Null  , 
	@Person_Notes varchar(max) =Null  , 
	@Person_Search varchar(max) =Null  , 
	@Person_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Person_TimeStamp]
    FROM [dbo].[Persons]
    	WHERE ([Person_ID] = @Person_ID)

    IF  @OldTimeStamp = @Person_TimeStamp
    BEGIN*/
		Update [dbo].[Persons] SET 
		/*[Person_ID] =@Person_ID, 
		[Dealer_ID] =@Dealer_ID, 
		[Person_Code] =@Person_Code, 
		[Person_NameAr] =@Person_NameAr, 
		[Person_NameEn] =@Person_NameEn, 
		[Person_Notes] =@Person_Notes, 
		[Person_Search] =@Person_Search*/
		/*WHERE ([Person_ID] = @Person_ID)*/
	/*END*/

	/*SELECT @Person_RowNumber = [Person_RowNumber], @Person_TimeStamp = [Person_TimeStamp]
    FROM [dbo].[Persons]
	WHERE ([Person_ID] = @Person_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Persons-Insert-Update]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	Insert OR Update record into table [dbo].[Persons]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Persons-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Persons-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Persons-Insert-Update]
	/*@Person_RowNumber int =Null OUTPUT , 
	@Person_ID uniqueidentifier =Null  , 
	@Dealer_ID uniqueidentifier =Null  , 
	@Person_Code varchar(50) =Null  , 
	@Person_NameAr varchar(300) =Null  , 
	@Person_NameEn varchar(300) =Null  , 
	@Person_Notes varchar(max) =Null  , 
	@Person_Search varchar(max) =Null  , 
	@Person_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Persons] 
					/*WHERE ([Person_ID] = @Person_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Persons](/*[Person_ID], [Dealer_ID], [Person_Code], [Person_NameAr], [Person_NameEn], [Person_Notes], [Person_Search]*/)
		VALUES     (/*@Person_ID, @Dealer_ID, @Person_Code, @Person_NameAr, @Person_NameEn, @Person_Notes, @Person_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Person_TimeStamp]
		FROM [dbo].[Persons]
    	WHERE ([Person_ID] = @Person_ID)

		IF  @OldTimeStamp = @Person_TimeStamp
		BEGIN*/
			Update [dbo].[Persons] SET 
			/*[Person_ID] =@Person_ID, 
			[Dealer_ID] =@Dealer_ID, 
			[Person_Code] =@Person_Code, 
			[Person_NameAr] =@Person_NameAr, 
			[Person_NameEn] =@Person_NameEn, 
			[Person_Notes] =@Person_Notes, 
			[Person_Search] =@Person_Search*/
			/*WHERE ([Person_ID] = @Person_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Person_RowNumber = [Person_RowNumber], @Person_TimeStamp = [Person_TimeStamp]
    FROM [dbo].[Persons]
	WHERE ([Person_ID] = @Person_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Persons-Delete]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	delete records from table [dbo].[Persons] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Persons-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Persons-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Persons-Delete]
	/*@Person_RowNumber int =null  , 
	@Person_ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Person_Code varchar(50) =null  , 
	@Person_NameAr varchar(300) =null  , 
	@Person_NameEn varchar(300) =null  , 
	@Person_Notes varchar(max) =null  , 
	@Person_Search varchar(max) =null  , 
	@Person_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Persons]
	WHERE /*( [Person_RowNumber] = ISNULL(@Person_RowNumber, [Person_RowNumber]) )
	AND ( [Person_ID] = ISNULL(@Person_ID, [Person_ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Person_Code] like ISNULL(@Person_Code, [Person_Code]) )
	AND ( [Person_NameAr] like ISNULL(@Person_NameAr, [Person_NameAr]) )
	AND ( [Person_NameEn] like ISNULL(@Person_NameEn, [Person_NameEn]) )
	AND ( [Person_Notes] like ISNULL(@Person_Notes, [Person_Notes]) )
	AND ( [Person_Search] like ISNULL(@Person_Search, [Person_Search]) )
	AND ( [Person_TimeStamp] = ISNULL(@Person_TimeStamp, [Person_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Persons-Select]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	select records from table [dbo].[Persons] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Persons-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Persons-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Persons-Select]
	/*@Person_RowNumber int =null  , 
	@Person_ID uniqueidentifier =null  , 
	@Dealer_ID uniqueidentifier =null  , 
	@Person_Code varchar(50) =null  , 
	@Person_NameAr varchar(300) =null  , 
	@Person_NameEn varchar(300) =null  , 
	@Person_Notes varchar(max) =null  , 
	@Person_Search varchar(max) =null  , 
	@Person_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Persons]
	WHERE /*( [Person_RowNumber] = ISNULL(@Person_RowNumber, [Person_RowNumber]) )
	AND ( [Person_ID] = ISNULL(@Person_ID, [Person_ID]) )
	AND ( [Dealer_ID] = ISNULL(@Dealer_ID, [Dealer_ID]) )
	AND ( [Person_Code] like ISNULL(@Person_Code, [Person_Code]) )
	AND ( [Person_NameAr] like ISNULL(@Person_NameAr, [Person_NameAr]) )
	AND ( [Person_NameEn] like ISNULL(@Person_NameEn, [Person_NameEn]) )
	AND ( [Person_Notes] like ISNULL(@Person_Notes, [Person_Notes]) )
	AND ( [Person_Search] like ISNULL(@Person_Search, [Person_Search]) )
	AND ( [Person_TimeStamp] = ISNULL(@Person_TimeStamp, [Person_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Products-Insert]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	Insert record into table [dbo].[Products]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Products-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Products-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Products-Insert]
	/*@Product_RowNumber int =Null OUTPUT , 
	@Product_ID uniqueidentifier =Null  , 
	@Product_Code varchar(50) =Null  , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@Product_NameAr varchar(300) =Null  , 
	@Product_NameEn varchar(300) =Null  , 
	@Product_Notes varchar(max) =Null  , 
	@Product_Search varchar(max) =Null  , 
	@Product_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Products](/*[Product_ID], [Product_Code], [ProductClassification_ID], [Product_NameAr], [Product_NameEn], [Product_Notes], [Product_Search]*/)
	VALUES     (/*@Product_ID, @Product_Code, @ProductClassification_ID, @Product_NameAr, @Product_NameEn, @Product_Notes, @Product_Search*/)

	/*SELECT @Product_RowNumber = [Product_RowNumber], @Product_TimeStamp = [Product_TimeStamp]
    FROM [dbo].[Products]
    WHERE  ( [Product_ID] =@Product_ID )
	AND  ( [Product_Code] =@Product_Code )
	AND  ( [ProductClassification_ID] =@ProductClassification_ID )
	AND  ( [Product_NameAr] =@Product_NameAr )
	AND  ( [Product_NameEn] =@Product_NameEn )
	AND  ( [Product_Notes] =@Product_Notes )
	AND  ( [Product_Search] =@Product_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Products-update]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	Update record in table [dbo].[Products]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Products-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Products-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Products-update]
	/*@Product_RowNumber int =Null OUTPUT , 
	@Product_ID uniqueidentifier =Null  , 
	@Product_Code varchar(50) =Null  , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@Product_NameAr varchar(300) =Null  , 
	@Product_NameEn varchar(300) =Null  , 
	@Product_Notes varchar(max) =Null  , 
	@Product_Search varchar(max) =Null  , 
	@Product_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Product_TimeStamp]
    FROM [dbo].[Products]
    	WHERE ([Product_ID] = @Product_ID)

    IF  @OldTimeStamp = @Product_TimeStamp
    BEGIN*/
		Update [dbo].[Products] SET 
		/*[Product_ID] =@Product_ID, 
		[Product_Code] =@Product_Code, 
		[ProductClassification_ID] =@ProductClassification_ID, 
		[Product_NameAr] =@Product_NameAr, 
		[Product_NameEn] =@Product_NameEn, 
		[Product_Notes] =@Product_Notes, 
		[Product_Search] =@Product_Search*/
		/*WHERE ([Product_ID] = @Product_ID)*/
	/*END*/

	/*SELECT @Product_RowNumber = [Product_RowNumber], @Product_TimeStamp = [Product_TimeStamp]
    FROM [dbo].[Products]
	WHERE ([Product_ID] = @Product_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Products-Insert-Update]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	Insert OR Update record into table [dbo].[Products]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Products-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Products-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Products-Insert-Update]
	/*@Product_RowNumber int =Null OUTPUT , 
	@Product_ID uniqueidentifier =Null  , 
	@Product_Code varchar(50) =Null  , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@Product_NameAr varchar(300) =Null  , 
	@Product_NameEn varchar(300) =Null  , 
	@Product_Notes varchar(max) =Null  , 
	@Product_Search varchar(max) =Null  , 
	@Product_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Products] 
					/*WHERE ([Product_ID] = @Product_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Products](/*[Product_ID], [Product_Code], [ProductClassification_ID], [Product_NameAr], [Product_NameEn], [Product_Notes], [Product_Search]*/)
		VALUES     (/*@Product_ID, @Product_Code, @ProductClassification_ID, @Product_NameAr, @Product_NameEn, @Product_Notes, @Product_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Product_TimeStamp]
		FROM [dbo].[Products]
    	WHERE ([Product_ID] = @Product_ID)

		IF  @OldTimeStamp = @Product_TimeStamp
		BEGIN*/
			Update [dbo].[Products] SET 
			/*[Product_ID] =@Product_ID, 
			[Product_Code] =@Product_Code, 
			[ProductClassification_ID] =@ProductClassification_ID, 
			[Product_NameAr] =@Product_NameAr, 
			[Product_NameEn] =@Product_NameEn, 
			[Product_Notes] =@Product_Notes, 
			[Product_Search] =@Product_Search*/
			/*WHERE ([Product_ID] = @Product_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Product_RowNumber = [Product_RowNumber], @Product_TimeStamp = [Product_TimeStamp]
    FROM [dbo].[Products]
	WHERE ([Product_ID] = @Product_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Products-Delete]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	delete records from table [dbo].[Products] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Products-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Products-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Products-Delete]
	/*@Product_RowNumber int =null  , 
	@Product_ID uniqueidentifier =null  , 
	@Product_Code varchar(50) =null  , 
	@ProductClassification_ID uniqueidentifier =null  , 
	@Product_NameAr varchar(300) =null  , 
	@Product_NameEn varchar(300) =null  , 
	@Product_Notes varchar(max) =null  , 
	@Product_Search varchar(max) =null  , 
	@Product_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Products]
	WHERE /*( [Product_RowNumber] = ISNULL(@Product_RowNumber, [Product_RowNumber]) )
	AND ( [Product_ID] = ISNULL(@Product_ID, [Product_ID]) )
	AND ( [Product_Code] like ISNULL(@Product_Code, [Product_Code]) )
	AND ( [ProductClassification_ID] = ISNULL(@ProductClassification_ID, [ProductClassification_ID]) )
	AND ( [Product_NameAr] like ISNULL(@Product_NameAr, [Product_NameAr]) )
	AND ( [Product_NameEn] like ISNULL(@Product_NameEn, [Product_NameEn]) )
	AND ( [Product_Notes] like ISNULL(@Product_Notes, [Product_Notes]) )
	AND ( [Product_Search] like ISNULL(@Product_Search, [Product_Search]) )
	AND ( [Product_TimeStamp] = ISNULL(@Product_TimeStamp, [Product_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Products-Select]    Script Date: [[20120914064959]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064959]]
-- Description:	select records from table [dbo].[Products] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Products-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Products-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Products-Select]
	/*@Product_RowNumber int =null  , 
	@Product_ID uniqueidentifier =null  , 
	@Product_Code varchar(50) =null  , 
	@ProductClassification_ID uniqueidentifier =null  , 
	@Product_NameAr varchar(300) =null  , 
	@Product_NameEn varchar(300) =null  , 
	@Product_Notes varchar(max) =null  , 
	@Product_Search varchar(max) =null  , 
	@Product_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Products]
	WHERE /*( [Product_RowNumber] = ISNULL(@Product_RowNumber, [Product_RowNumber]) )
	AND ( [Product_ID] = ISNULL(@Product_ID, [Product_ID]) )
	AND ( [Product_Code] like ISNULL(@Product_Code, [Product_Code]) )
	AND ( [ProductClassification_ID] = ISNULL(@ProductClassification_ID, [ProductClassification_ID]) )
	AND ( [Product_NameAr] like ISNULL(@Product_NameAr, [Product_NameAr]) )
	AND ( [Product_NameEn] like ISNULL(@Product_NameEn, [Product_NameEn]) )
	AND ( [Product_Notes] like ISNULL(@Product_Notes, [Product_Notes]) )
	AND ( [Product_Search] like ISNULL(@Product_Search, [Product_Search]) )
	AND ( [Product_TimeStamp] = ISNULL(@Product_TimeStamp, [Product_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Insert]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Insert record into table [dbo].[ProductsClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Insert]
	/*@ProductClassification_RowNumber int =Null OUTPUT , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@ProductClassification_Code varchar(50) =Null  , 
	@ProductClassification_NameAr varchar(300) =Null  , 
	@ProductClassification_NameEn varchar(300) =Null  , 
	@ProductClassification_Notes varchar(max) =Null  , 
	@ProductClassification_Search varchar(max) =Null  , 
	@ProductClassification_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[ProductsClassifications](/*[ProductClassification_ID], [ProductClassification_Code], [ProductClassification_NameAr], [ProductClassification_NameEn], [ProductClassification_Notes], [ProductClassification_Search]*/)
	VALUES     (/*@ProductClassification_ID, @ProductClassification_Code, @ProductClassification_NameAr, @ProductClassification_NameEn, @ProductClassification_Notes, @ProductClassification_Search*/)

	/*SELECT @ProductClassification_RowNumber = [ProductClassification_RowNumber], @ProductClassification_TimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
    WHERE  ( [ProductClassification_ID] =@ProductClassification_ID )
	AND  ( [ProductClassification_Code] =@ProductClassification_Code )
	AND  ( [ProductClassification_NameAr] =@ProductClassification_NameAr )
	AND  ( [ProductClassification_NameEn] =@ProductClassification_NameEn )
	AND  ( [ProductClassification_Notes] =@ProductClassification_Notes )
	AND  ( [ProductClassification_Search] =@ProductClassification_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-update]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Update record in table [dbo].[ProductsClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-update]
	/*@ProductClassification_RowNumber int =Null OUTPUT , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@ProductClassification_Code varchar(50) =Null  , 
	@ProductClassification_NameAr varchar(300) =Null  , 
	@ProductClassification_NameEn varchar(300) =Null  , 
	@ProductClassification_Notes varchar(max) =Null  , 
	@ProductClassification_Search varchar(max) =Null  , 
	@ProductClassification_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
    	WHERE ([ProductClassification_ID] = @ProductClassification_ID)

    IF  @OldTimeStamp = @ProductClassification_TimeStamp
    BEGIN*/
		Update [dbo].[ProductsClassifications] SET 
		/*[ProductClassification_ID] =@ProductClassification_ID, 
		[ProductClassification_Code] =@ProductClassification_Code, 
		[ProductClassification_NameAr] =@ProductClassification_NameAr, 
		[ProductClassification_NameEn] =@ProductClassification_NameEn, 
		[ProductClassification_Notes] =@ProductClassification_Notes, 
		[ProductClassification_Search] =@ProductClassification_Search*/
		/*WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
	/*END*/

	/*SELECT @ProductClassification_RowNumber = [ProductClassification_RowNumber], @ProductClassification_TimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
	WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Insert-Update]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Insert OR Update record into table [dbo].[ProductsClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Insert-Update]
	/*@ProductClassification_RowNumber int =Null OUTPUT , 
	@ProductClassification_ID uniqueidentifier =Null  , 
	@ProductClassification_Code varchar(50) =Null  , 
	@ProductClassification_NameAr varchar(300) =Null  , 
	@ProductClassification_NameEn varchar(300) =Null  , 
	@ProductClassification_Notes varchar(max) =Null  , 
	@ProductClassification_Search varchar(max) =Null  , 
	@ProductClassification_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[ProductsClassifications] 
					/*WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[ProductsClassifications](/*[ProductClassification_ID], [ProductClassification_Code], [ProductClassification_NameAr], [ProductClassification_NameEn], [ProductClassification_Notes], [ProductClassification_Search]*/)
		VALUES     (/*@ProductClassification_ID, @ProductClassification_Code, @ProductClassification_NameAr, @ProductClassification_NameEn, @ProductClassification_Notes, @ProductClassification_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [ProductClassification_TimeStamp]
		FROM [dbo].[ProductsClassifications]
    	WHERE ([ProductClassification_ID] = @ProductClassification_ID)

		IF  @OldTimeStamp = @ProductClassification_TimeStamp
		BEGIN*/
			Update [dbo].[ProductsClassifications] SET 
			/*[ProductClassification_ID] =@ProductClassification_ID, 
			[ProductClassification_Code] =@ProductClassification_Code, 
			[ProductClassification_NameAr] =@ProductClassification_NameAr, 
			[ProductClassification_NameEn] =@ProductClassification_NameEn, 
			[ProductClassification_Notes] =@ProductClassification_Notes, 
			[ProductClassification_Search] =@ProductClassification_Search*/
			/*WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @ProductClassification_RowNumber = [ProductClassification_RowNumber], @ProductClassification_TimeStamp = [ProductClassification_TimeStamp]
    FROM [dbo].[ProductsClassifications]
	WHERE ([ProductClassification_ID] = @ProductClassification_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Delete]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	delete records from table [dbo].[ProductsClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Delete]
	/*@ProductClassification_RowNumber int =null  , 
	@ProductClassification_ID uniqueidentifier =null  , 
	@ProductClassification_Code varchar(50) =null  , 
	@ProductClassification_NameAr varchar(300) =null  , 
	@ProductClassification_NameEn varchar(300) =null  , 
	@ProductClassification_Notes varchar(max) =null  , 
	@ProductClassification_Search varchar(max) =null  , 
	@ProductClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[ProductsClassifications]
	WHERE /*( [ProductClassification_RowNumber] = ISNULL(@ProductClassification_RowNumber, [ProductClassification_RowNumber]) )
	AND ( [ProductClassification_ID] = ISNULL(@ProductClassification_ID, [ProductClassification_ID]) )
	AND ( [ProductClassification_Code] like ISNULL(@ProductClassification_Code, [ProductClassification_Code]) )
	AND ( [ProductClassification_NameAr] like ISNULL(@ProductClassification_NameAr, [ProductClassification_NameAr]) )
	AND ( [ProductClassification_NameEn] like ISNULL(@ProductClassification_NameEn, [ProductClassification_NameEn]) )
	AND ( [ProductClassification_Notes] like ISNULL(@ProductClassification_Notes, [ProductClassification_Notes]) )
	AND ( [ProductClassification_Search] like ISNULL(@ProductClassification_Search, [ProductClassification_Search]) )
	AND ( [ProductClassification_TimeStamp] = ISNULL(@ProductClassification_TimeStamp, [ProductClassification_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[ProductsClassifications-Select]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	select records from table [dbo].[ProductsClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[ProductsClassifications-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[ProductsClassifications-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[ProductsClassifications-Select]
	/*@ProductClassification_RowNumber int =null  , 
	@ProductClassification_ID uniqueidentifier =null  , 
	@ProductClassification_Code varchar(50) =null  , 
	@ProductClassification_NameAr varchar(300) =null  , 
	@ProductClassification_NameEn varchar(300) =null  , 
	@ProductClassification_Notes varchar(max) =null  , 
	@ProductClassification_Search varchar(max) =null  , 
	@ProductClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[ProductsClassifications]
	WHERE /*( [ProductClassification_RowNumber] = ISNULL(@ProductClassification_RowNumber, [ProductClassification_RowNumber]) )
	AND ( [ProductClassification_ID] = ISNULL(@ProductClassification_ID, [ProductClassification_ID]) )
	AND ( [ProductClassification_Code] like ISNULL(@ProductClassification_Code, [ProductClassification_Code]) )
	AND ( [ProductClassification_NameAr] like ISNULL(@ProductClassification_NameAr, [ProductClassification_NameAr]) )
	AND ( [ProductClassification_NameEn] like ISNULL(@ProductClassification_NameEn, [ProductClassification_NameEn]) )
	AND ( [ProductClassification_Notes] like ISNULL(@ProductClassification_Notes, [ProductClassification_Notes]) )
	AND ( [ProductClassification_Search] like ISNULL(@ProductClassification_Search, [ProductClassification_Search]) )
	AND ( [ProductClassification_TimeStamp] = ISNULL(@ProductClassification_TimeStamp, [ProductClassification_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TablesNames-Insert]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Insert record into table [dbo].[TablesNames]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Insert]
	/*@TableName_RowNumber int =Null  , 
	@TableName_ID uniqueidentifier =Null  , 
	@TableName_NameAr varchar(200) =Null  , 
	@TableName_NameEn varchar(200) =Null  , 
	@TableName_Search varchar(max) =Null  , 
	@TableName_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[TablesNames](/*[TableName_RowNumber], [TableName_ID], [TableName_NameAr], [TableName_NameEn], [TableName_Search]*/)
	VALUES     (/*@TableName_RowNumber, @TableName_ID, @TableName_NameAr, @TableName_NameEn, @TableName_Search*/)

	/*SELECT @TableName_TimeStamp = [TableName_TimeStamp]
    FROM [dbo].[TablesNames]
    WHERE  ( [TableName_RowNumber] =@TableName_RowNumber )
	AND  ( [TableName_ID] =@TableName_ID )
	AND  ( [TableName_NameAr] =@TableName_NameAr )
	AND  ( [TableName_NameEn] =@TableName_NameEn )
	AND  ( [TableName_Search] =@TableName_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TablesNames-update]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Update record in table [dbo].[TablesNames]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-update]
	/*@TableName_RowNumber int =Null  , 
	@TableName_ID uniqueidentifier =Null  , 
	@TableName_NameAr varchar(200) =Null  , 
	@TableName_NameEn varchar(200) =Null  , 
	@TableName_Search varchar(max) =Null  , 
	@TableName_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [TableName_TimeStamp]
    FROM [dbo].[TablesNames]
    	WHERE ([TableName_ID] = @TableName_ID)

    IF  @OldTimeStamp = @TableName_TimeStamp
    BEGIN*/
		Update [dbo].[TablesNames] SET 
		/*[TableName_RowNumber] =@TableName_RowNumber, 
		[TableName_ID] =@TableName_ID, 
		[TableName_NameAr] =@TableName_NameAr, 
		[TableName_NameEn] =@TableName_NameEn, 
		[TableName_Search] =@TableName_Search*/
		/*WHERE ([TableName_ID] = @TableName_ID)*/
	/*END*/

	/*SELECT @TableName_TimeStamp = [TableName_TimeStamp]
    FROM [dbo].[TablesNames]
	WHERE ([TableName_ID] = @TableName_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TablesNames-Insert-Update]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	Insert OR Update record into table [dbo].[TablesNames]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Insert-Update]
	/*@TableName_RowNumber int =Null  , 
	@TableName_ID uniqueidentifier =Null  , 
	@TableName_NameAr varchar(200) =Null  , 
	@TableName_NameEn varchar(200) =Null  , 
	@TableName_Search varchar(max) =Null  , 
	@TableName_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[TablesNames] 
					/*WHERE ([TableName_ID] = @TableName_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[TablesNames](/*[TableName_RowNumber], [TableName_ID], [TableName_NameAr], [TableName_NameEn], [TableName_Search]*/)
		VALUES     (/*@TableName_RowNumber, @TableName_ID, @TableName_NameAr, @TableName_NameEn, @TableName_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [TableName_TimeStamp]
		FROM [dbo].[TablesNames]
    	WHERE ([TableName_ID] = @TableName_ID)

		IF  @OldTimeStamp = @TableName_TimeStamp
		BEGIN*/
			Update [dbo].[TablesNames] SET 
			/*[TableName_RowNumber] =@TableName_RowNumber, 
			[TableName_ID] =@TableName_ID, 
			[TableName_NameAr] =@TableName_NameAr, 
			[TableName_NameEn] =@TableName_NameEn, 
			[TableName_Search] =@TableName_Search*/
			/*WHERE ([TableName_ID] = @TableName_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @TableName_TimeStamp = [TableName_TimeStamp]
    FROM [dbo].[TablesNames]
	WHERE ([TableName_ID] = @TableName_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TablesNames-Delete]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	delete records from table [dbo].[TablesNames] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Delete]
	/*@TableName_RowNumber int =null  , 
	@TableName_ID uniqueidentifier =null  , 
	@TableName_NameAr varchar(200) =null  , 
	@TableName_NameEn varchar(200) =null  , 
	@TableName_Search varchar(max) =null  , 
	@TableName_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[TablesNames]
	WHERE /*( [TableName_RowNumber] = ISNULL(@TableName_RowNumber, [TableName_RowNumber]) )
	AND ( [TableName_ID] = ISNULL(@TableName_ID, [TableName_ID]) )
	AND ( [TableName_NameAr] like ISNULL(@TableName_NameAr, [TableName_NameAr]) )
	AND ( [TableName_NameEn] like ISNULL(@TableName_NameEn, [TableName_NameEn]) )
	AND ( [TableName_Search] like ISNULL(@TableName_Search, [TableName_Search]) )
	AND ( [TableName_TimeStamp] = ISNULL(@TableName_TimeStamp, [TableName_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TablesNames-Select]    Script Date: [[20120914065000]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065000]]
-- Description:	select records from table [dbo].[TablesNames] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TablesNames-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TablesNames-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TablesNames-Select]
	/*@TableName_RowNumber int =null  , 
	@TableName_ID uniqueidentifier =null  , 
	@TableName_NameAr varchar(200) =null  , 
	@TableName_NameEn varchar(200) =null  , 
	@TableName_Search varchar(max) =null  , 
	@TableName_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[TablesNames]
	WHERE /*( [TableName_RowNumber] = ISNULL(@TableName_RowNumber, [TableName_RowNumber]) )
	AND ( [TableName_ID] = ISNULL(@TableName_ID, [TableName_ID]) )
	AND ( [TableName_NameAr] like ISNULL(@TableName_NameAr, [TableName_NameAr]) )
	AND ( [TableName_NameEn] like ISNULL(@TableName_NameEn, [TableName_NameEn]) )
	AND ( [TableName_Search] like ISNULL(@TableName_Search, [TableName_Search]) )
	AND ( [TableName_TimeStamp] = ISNULL(@TableName_TimeStamp, [TableName_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TypeOfTrades-Insert]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	Insert record into table [dbo].[TypeOfTrades]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TypeOfTrades-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TypeOfTrades-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TypeOfTrades-Insert]
	/*@TypeOfTrade_RowNumber int =Null OUTPUT , 
	@TypeOfTrade_ID uniqueidentifier =Null  , 
	@TypeOfTrade_Code varchar(50) =Null  , 
	@TypeOfTrade_NameAr varchar(300) =Null  , 
	@TypeOfTrade_NameEn varchar(300) =Null  , 
	@TypeOfTrade_Notes varchar(max) =Null  , 
	@TypeOfTrade_Search varchar(max) =Null  , 
	@TypeOfTrade_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[TypeOfTrades](/*[TypeOfTrade_ID], [TypeOfTrade_Code], [TypeOfTrade_NameAr], [TypeOfTrade_NameEn], [TypeOfTrade_Notes], [TypeOfTrade_Search]*/)
	VALUES     (/*@TypeOfTrade_ID, @TypeOfTrade_Code, @TypeOfTrade_NameAr, @TypeOfTrade_NameEn, @TypeOfTrade_Notes, @TypeOfTrade_Search*/)

	/*SELECT @TypeOfTrade_RowNumber = [TypeOfTrade_RowNumber], @TypeOfTrade_TimeStamp = [TypeOfTrade_TimeStamp]
    FROM [dbo].[TypeOfTrades]
    WHERE  ( [TypeOfTrade_ID] =@TypeOfTrade_ID )
	AND  ( [TypeOfTrade_Code] =@TypeOfTrade_Code )
	AND  ( [TypeOfTrade_NameAr] =@TypeOfTrade_NameAr )
	AND  ( [TypeOfTrade_NameEn] =@TypeOfTrade_NameEn )
	AND  ( [TypeOfTrade_Notes] =@TypeOfTrade_Notes )
	AND  ( [TypeOfTrade_Search] =@TypeOfTrade_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TypeOfTrades-update]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	Update record in table [dbo].[TypeOfTrades]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TypeOfTrades-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TypeOfTrades-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TypeOfTrades-update]
	/*@TypeOfTrade_RowNumber int =Null OUTPUT , 
	@TypeOfTrade_ID uniqueidentifier =Null  , 
	@TypeOfTrade_Code varchar(50) =Null  , 
	@TypeOfTrade_NameAr varchar(300) =Null  , 
	@TypeOfTrade_NameEn varchar(300) =Null  , 
	@TypeOfTrade_Notes varchar(max) =Null  , 
	@TypeOfTrade_Search varchar(max) =Null  , 
	@TypeOfTrade_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [TypeOfTrade_TimeStamp]
    FROM [dbo].[TypeOfTrades]
    	WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)

    IF  @OldTimeStamp = @TypeOfTrade_TimeStamp
    BEGIN*/
		Update [dbo].[TypeOfTrades] SET 
		/*[TypeOfTrade_ID] =@TypeOfTrade_ID, 
		[TypeOfTrade_Code] =@TypeOfTrade_Code, 
		[TypeOfTrade_NameAr] =@TypeOfTrade_NameAr, 
		[TypeOfTrade_NameEn] =@TypeOfTrade_NameEn, 
		[TypeOfTrade_Notes] =@TypeOfTrade_Notes, 
		[TypeOfTrade_Search] =@TypeOfTrade_Search*/
		/*WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)*/
	/*END*/

	/*SELECT @TypeOfTrade_RowNumber = [TypeOfTrade_RowNumber], @TypeOfTrade_TimeStamp = [TypeOfTrade_TimeStamp]
    FROM [dbo].[TypeOfTrades]
	WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TypeOfTrades-Insert-Update]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	Insert OR Update record into table [dbo].[TypeOfTrades]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TypeOfTrades-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TypeOfTrades-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TypeOfTrades-Insert-Update]
	/*@TypeOfTrade_RowNumber int =Null OUTPUT , 
	@TypeOfTrade_ID uniqueidentifier =Null  , 
	@TypeOfTrade_Code varchar(50) =Null  , 
	@TypeOfTrade_NameAr varchar(300) =Null  , 
	@TypeOfTrade_NameEn varchar(300) =Null  , 
	@TypeOfTrade_Notes varchar(max) =Null  , 
	@TypeOfTrade_Search varchar(max) =Null  , 
	@TypeOfTrade_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[TypeOfTrades] 
					/*WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[TypeOfTrades](/*[TypeOfTrade_ID], [TypeOfTrade_Code], [TypeOfTrade_NameAr], [TypeOfTrade_NameEn], [TypeOfTrade_Notes], [TypeOfTrade_Search]*/)
		VALUES     (/*@TypeOfTrade_ID, @TypeOfTrade_Code, @TypeOfTrade_NameAr, @TypeOfTrade_NameEn, @TypeOfTrade_Notes, @TypeOfTrade_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [TypeOfTrade_TimeStamp]
		FROM [dbo].[TypeOfTrades]
    	WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)

		IF  @OldTimeStamp = @TypeOfTrade_TimeStamp
		BEGIN*/
			Update [dbo].[TypeOfTrades] SET 
			/*[TypeOfTrade_ID] =@TypeOfTrade_ID, 
			[TypeOfTrade_Code] =@TypeOfTrade_Code, 
			[TypeOfTrade_NameAr] =@TypeOfTrade_NameAr, 
			[TypeOfTrade_NameEn] =@TypeOfTrade_NameEn, 
			[TypeOfTrade_Notes] =@TypeOfTrade_Notes, 
			[TypeOfTrade_Search] =@TypeOfTrade_Search*/
			/*WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @TypeOfTrade_RowNumber = [TypeOfTrade_RowNumber], @TypeOfTrade_TimeStamp = [TypeOfTrade_TimeStamp]
    FROM [dbo].[TypeOfTrades]
	WHERE ([TypeOfTrade_ID] = @TypeOfTrade_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TypeOfTrades-Delete]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	delete records from table [dbo].[TypeOfTrades] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TypeOfTrades-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TypeOfTrades-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TypeOfTrades-Delete]
	/*@TypeOfTrade_RowNumber int =null  , 
	@TypeOfTrade_ID uniqueidentifier =null  , 
	@TypeOfTrade_Code varchar(50) =null  , 
	@TypeOfTrade_NameAr varchar(300) =null  , 
	@TypeOfTrade_NameEn varchar(300) =null  , 
	@TypeOfTrade_Notes varchar(max) =null  , 
	@TypeOfTrade_Search varchar(max) =null  , 
	@TypeOfTrade_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[TypeOfTrades]
	WHERE /*( [TypeOfTrade_RowNumber] = ISNULL(@TypeOfTrade_RowNumber, [TypeOfTrade_RowNumber]) )
	AND ( [TypeOfTrade_ID] = ISNULL(@TypeOfTrade_ID, [TypeOfTrade_ID]) )
	AND ( [TypeOfTrade_Code] like ISNULL(@TypeOfTrade_Code, [TypeOfTrade_Code]) )
	AND ( [TypeOfTrade_NameAr] like ISNULL(@TypeOfTrade_NameAr, [TypeOfTrade_NameAr]) )
	AND ( [TypeOfTrade_NameEn] like ISNULL(@TypeOfTrade_NameEn, [TypeOfTrade_NameEn]) )
	AND ( [TypeOfTrade_Notes] like ISNULL(@TypeOfTrade_Notes, [TypeOfTrade_Notes]) )
	AND ( [TypeOfTrade_Search] like ISNULL(@TypeOfTrade_Search, [TypeOfTrade_Search]) )
	AND ( [TypeOfTrade_TimeStamp] = ISNULL(@TypeOfTrade_TimeStamp, [TypeOfTrade_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[TypeOfTrades-Select]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	select records from table [dbo].[TypeOfTrades] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[TypeOfTrades-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[TypeOfTrades-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[TypeOfTrades-Select]
	/*@TypeOfTrade_RowNumber int =null  , 
	@TypeOfTrade_ID uniqueidentifier =null  , 
	@TypeOfTrade_Code varchar(50) =null  , 
	@TypeOfTrade_NameAr varchar(300) =null  , 
	@TypeOfTrade_NameEn varchar(300) =null  , 
	@TypeOfTrade_Notes varchar(max) =null  , 
	@TypeOfTrade_Search varchar(max) =null  , 
	@TypeOfTrade_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[TypeOfTrades]
	WHERE /*( [TypeOfTrade_RowNumber] = ISNULL(@TypeOfTrade_RowNumber, [TypeOfTrade_RowNumber]) )
	AND ( [TypeOfTrade_ID] = ISNULL(@TypeOfTrade_ID, [TypeOfTrade_ID]) )
	AND ( [TypeOfTrade_Code] like ISNULL(@TypeOfTrade_Code, [TypeOfTrade_Code]) )
	AND ( [TypeOfTrade_NameAr] like ISNULL(@TypeOfTrade_NameAr, [TypeOfTrade_NameAr]) )
	AND ( [TypeOfTrade_NameEn] like ISNULL(@TypeOfTrade_NameEn, [TypeOfTrade_NameEn]) )
	AND ( [TypeOfTrade_Notes] like ISNULL(@TypeOfTrade_Notes, [TypeOfTrade_Notes]) )
	AND ( [TypeOfTrade_Search] like ISNULL(@TypeOfTrade_Search, [TypeOfTrade_Search]) )
	AND ( [TypeOfTrade_TimeStamp] = ISNULL(@TypeOfTrade_TimeStamp, [TypeOfTrade_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users-Insert]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	Insert record into table [dbo].[Users]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users-Insert]
	/*@User_RowNumber int =Null OUTPUT , 
	@User_ID uniqueidentifier =Null  , 
	@User_NameAr varchar(200) =Null  , 
	@User_NameEn varchar(200) =Null  , 
	@User_LoginName varchar(200) =Null  , 
	@User_Password varchar(100) =Null  , 
	@User_Email varchar(100) =Null  , 
	@User_Search varchar(max) =Null  , 
	@User_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Users](/*[User_ID], [User_NameAr], [User_NameEn], [User_LoginName], [User_Password], [User_Email], [User_Search]*/)
	VALUES     (/*@User_ID, @User_NameAr, @User_NameEn, @User_LoginName, @User_Password, @User_Email, @User_Search*/)

	/*SELECT @User_RowNumber = [User_RowNumber], @User_TimeStamp = [User_TimeStamp]
    FROM [dbo].[Users]
    WHERE  ( [User_ID] =@User_ID )
	AND  ( [User_NameAr] =@User_NameAr )
	AND  ( [User_NameEn] =@User_NameEn )
	AND  ( [User_LoginName] =@User_LoginName )
	AND  ( [User_Password] =@User_Password )
	AND  ( [User_Email] =@User_Email )
	AND  ( [User_Search] =@User_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users-update]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	Update record in table [dbo].[Users]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users-update]
	/*@User_RowNumber int =Null OUTPUT , 
	@User_ID uniqueidentifier =Null  , 
	@User_NameAr varchar(200) =Null  , 
	@User_NameEn varchar(200) =Null  , 
	@User_LoginName varchar(200) =Null  , 
	@User_Password varchar(100) =Null  , 
	@User_Email varchar(100) =Null  , 
	@User_Search varchar(max) =Null  , 
	@User_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [User_TimeStamp]
    FROM [dbo].[Users]
    	WHERE ([User_ID] = @User_ID)

    IF  @OldTimeStamp = @User_TimeStamp
    BEGIN*/
		Update [dbo].[Users] SET 
		/*[User_ID] =@User_ID, 
		[User_NameAr] =@User_NameAr, 
		[User_NameEn] =@User_NameEn, 
		[User_LoginName] =@User_LoginName, 
		[User_Password] =@User_Password, 
		[User_Email] =@User_Email, 
		[User_Search] =@User_Search*/
		/*WHERE ([User_ID] = @User_ID)*/
	/*END*/

	/*SELECT @User_RowNumber = [User_RowNumber], @User_TimeStamp = [User_TimeStamp]
    FROM [dbo].[Users]
	WHERE ([User_ID] = @User_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users-Insert-Update]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	Insert OR Update record into table [dbo].[Users]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users-Insert-Update]
	/*@User_RowNumber int =Null OUTPUT , 
	@User_ID uniqueidentifier =Null  , 
	@User_NameAr varchar(200) =Null  , 
	@User_NameEn varchar(200) =Null  , 
	@User_LoginName varchar(200) =Null  , 
	@User_Password varchar(100) =Null  , 
	@User_Email varchar(100) =Null  , 
	@User_Search varchar(max) =Null  , 
	@User_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Users] 
					/*WHERE ([User_ID] = @User_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Users](/*[User_ID], [User_NameAr], [User_NameEn], [User_LoginName], [User_Password], [User_Email], [User_Search]*/)
		VALUES     (/*@User_ID, @User_NameAr, @User_NameEn, @User_LoginName, @User_Password, @User_Email, @User_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [User_TimeStamp]
		FROM [dbo].[Users]
    	WHERE ([User_ID] = @User_ID)

		IF  @OldTimeStamp = @User_TimeStamp
		BEGIN*/
			Update [dbo].[Users] SET 
			/*[User_ID] =@User_ID, 
			[User_NameAr] =@User_NameAr, 
			[User_NameEn] =@User_NameEn, 
			[User_LoginName] =@User_LoginName, 
			[User_Password] =@User_Password, 
			[User_Email] =@User_Email, 
			[User_Search] =@User_Search*/
			/*WHERE ([User_ID] = @User_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @User_RowNumber = [User_RowNumber], @User_TimeStamp = [User_TimeStamp]
    FROM [dbo].[Users]
	WHERE ([User_ID] = @User_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users-Delete]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	delete records from table [dbo].[Users] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users-Delete]
	/*@User_RowNumber int =null  , 
	@User_ID uniqueidentifier =null  , 
	@User_NameAr varchar(200) =null  , 
	@User_NameEn varchar(200) =null  , 
	@User_LoginName varchar(200) =null  , 
	@User_Password varchar(100) =null  , 
	@User_Email varchar(100) =null  , 
	@User_Search varchar(max) =null  , 
	@User_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Users]
	WHERE /*( [User_RowNumber] = ISNULL(@User_RowNumber, [User_RowNumber]) )
	AND ( [User_ID] = ISNULL(@User_ID, [User_ID]) )
	AND ( [User_NameAr] like ISNULL(@User_NameAr, [User_NameAr]) )
	AND ( [User_NameEn] like ISNULL(@User_NameEn, [User_NameEn]) )
	AND ( [User_LoginName] like ISNULL(@User_LoginName, [User_LoginName]) )
	AND ( [User_Password] like ISNULL(@User_Password, [User_Password]) )
	AND ( [User_Email] like ISNULL(@User_Email, [User_Email]) )
	AND ( [User_Search] like ISNULL(@User_Search, [User_Search]) )
	AND ( [User_TimeStamp] = ISNULL(@User_TimeStamp, [User_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users-Select]    Script Date: [[20120914065001]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065001]]
-- Description:	select records from table [dbo].[Users] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users-Select]
	/*@User_RowNumber int =null  , 
	@User_ID uniqueidentifier =null  , 
	@User_NameAr varchar(200) =null  , 
	@User_NameEn varchar(200) =null  , 
	@User_LoginName varchar(200) =null  , 
	@User_Password varchar(100) =null  , 
	@User_Email varchar(100) =null  , 
	@User_Search varchar(max) =null  , 
	@User_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Users]
	WHERE /*( [User_RowNumber] = ISNULL(@User_RowNumber, [User_RowNumber]) )
	AND ( [User_ID] = ISNULL(@User_ID, [User_ID]) )
	AND ( [User_NameAr] like ISNULL(@User_NameAr, [User_NameAr]) )
	AND ( [User_NameEn] like ISNULL(@User_NameEn, [User_NameEn]) )
	AND ( [User_LoginName] like ISNULL(@User_LoginName, [User_LoginName]) )
	AND ( [User_Password] like ISNULL(@User_Password, [User_Password]) )
	AND ( [User_Email] like ISNULL(@User_Email, [User_Email]) )
	AND ( [User_Search] like ISNULL(@User_Search, [User_Search]) )
	AND ( [User_TimeStamp] = ISNULL(@User_TimeStamp, [User_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users_Groups-Insert]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	Insert record into table [dbo].[Users_Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users_Groups-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users_Groups-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users_Groups-Insert]
	/*@RowNumber int =Null  , 
	@ID uniqueidentifier =Null  , 
	@User_ID uniqueidentifier =Null  , 
	@Group_ID uniqueidentifier =Null  , 
	@User_Group_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Users_Groups](/*[RowNumber], [ID], [User_ID], [Group_ID]*/)
	VALUES     (/*@RowNumber, @ID, @User_ID, @Group_ID*/)

	/*SELECT @User_Group_TimeStamp = [User_Group_TimeStamp]
    FROM [dbo].[Users_Groups]
    WHERE  ( [RowNumber] =@RowNumber )
	AND  ( [ID] =@ID )
	AND  ( [User_ID] =@User_ID )
	AND  ( [Group_ID] =@Group_ID )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users_Groups-update]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	Update record in table [dbo].[Users_Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users_Groups-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users_Groups-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users_Groups-update]
	/*@RowNumber int =Null  , 
	@ID uniqueidentifier =Null  , 
	@User_ID uniqueidentifier =Null  , 
	@Group_ID uniqueidentifier =Null  , 
	@User_Group_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [User_Group_TimeStamp]
    FROM [dbo].[Users_Groups]
    	WHERE ([ID] = @ID)

    IF  @OldTimeStamp = @User_Group_TimeStamp
    BEGIN*/
		Update [dbo].[Users_Groups] SET 
		/*[RowNumber] =@RowNumber, 
		[ID] =@ID, 
		[User_ID] =@User_ID, 
		[Group_ID] =@Group_ID*/
		/*WHERE ([ID] = @ID)*/
	/*END*/

	/*SELECT @User_Group_TimeStamp = [User_Group_TimeStamp]
    FROM [dbo].[Users_Groups]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users_Groups-Insert-Update]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	Insert OR Update record into table [dbo].[Users_Groups]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users_Groups-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users_Groups-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users_Groups-Insert-Update]
	/*@RowNumber int =Null  , 
	@ID uniqueidentifier =Null  , 
	@User_ID uniqueidentifier =Null  , 
	@Group_ID uniqueidentifier =Null  , 
	@User_Group_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Users_Groups] 
					/*WHERE ([ID] = @ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Users_Groups](/*[RowNumber], [ID], [User_ID], [Group_ID]*/)
		VALUES     (/*@RowNumber, @ID, @User_ID, @Group_ID*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [User_Group_TimeStamp]
		FROM [dbo].[Users_Groups]
    	WHERE ([ID] = @ID)

		IF  @OldTimeStamp = @User_Group_TimeStamp
		BEGIN*/
			Update [dbo].[Users_Groups] SET 
			/*[RowNumber] =@RowNumber, 
			[ID] =@ID, 
			[User_ID] =@User_ID, 
			[Group_ID] =@Group_ID*/
			/*WHERE ([ID] = @ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @User_Group_TimeStamp = [User_Group_TimeStamp]
    FROM [dbo].[Users_Groups]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users_Groups-Delete]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	delete records from table [dbo].[Users_Groups] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users_Groups-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users_Groups-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users_Groups-Delete]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@User_ID uniqueidentifier =null  , 
	@Group_ID uniqueidentifier =null  , 
	@User_Group_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Users_Groups]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [User_ID] = ISNULL(@User_ID, [User_ID]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [User_Group_TimeStamp] = ISNULL(@User_Group_TimeStamp, [User_Group_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Users_Groups-Select]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	select records from table [dbo].[Users_Groups] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Users_Groups-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Users_Groups-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Users_Groups-Select]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@User_ID uniqueidentifier =null  , 
	@Group_ID uniqueidentifier =null  , 
	@User_Group_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Users_Groups]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [User_ID] = ISNULL(@User_ID, [User_ID]) )
	AND ( [Group_ID] = ISNULL(@Group_ID, [Group_ID]) )
	AND ( [User_Group_TimeStamp] = ISNULL(@User_Group_TimeStamp, [User_Group_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[UsersLogs-Insert]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	Insert record into table [dbo].[UsersLogs]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[UsersLogs-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[UsersLogs-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[UsersLogs-Insert]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@User_ID uniqueidentifier =Null  , 
	@Date datetime =Null  , 
	@Table_ID uniqueidentifier =Null  , 
	@Event_ID uniqueidentifier =Null  , 
	@Item_ID uniqueidentifier =Null  , 
	@UsersLog_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[UsersLogs](/*[ID], [User_ID], [Date], [Table_ID], [Event_ID], [Item_ID]*/)
	VALUES     (/*@ID, @User_ID, @Date, @Table_ID, @Event_ID, @Item_ID*/)

	/*SELECT @RowNumber = [RowNumber], @UsersLog_TimeStamp = [UsersLog_TimeStamp]
    FROM [dbo].[UsersLogs]
    WHERE  ( [ID] =@ID )
	AND  ( [User_ID] =@User_ID )
	AND  ( [Date] =@Date )
	AND  ( [Table_ID] =@Table_ID )
	AND  ( [Event_ID] =@Event_ID )
	AND  ( [Item_ID] =@Item_ID )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[UsersLogs-update]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	Update record in table [dbo].[UsersLogs]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[UsersLogs-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[UsersLogs-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[UsersLogs-update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@User_ID uniqueidentifier =Null  , 
	@Date datetime =Null  , 
	@Table_ID uniqueidentifier =Null  , 
	@Event_ID uniqueidentifier =Null  , 
	@Item_ID uniqueidentifier =Null  , 
	@UsersLog_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [UsersLog_TimeStamp]
    FROM [dbo].[UsersLogs]
    	WHERE ([ID] = @ID)

    IF  @OldTimeStamp = @UsersLog_TimeStamp
    BEGIN*/
		Update [dbo].[UsersLogs] SET 
		/*[ID] =@ID, 
		[User_ID] =@User_ID, 
		[Date] =@Date, 
		[Table_ID] =@Table_ID, 
		[Event_ID] =@Event_ID, 
		[Item_ID] =@Item_ID*/
		/*WHERE ([ID] = @ID)*/
	/*END*/

	/*SELECT @RowNumber = [RowNumber], @UsersLog_TimeStamp = [UsersLog_TimeStamp]
    FROM [dbo].[UsersLogs]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[UsersLogs-Insert-Update]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	Insert OR Update record into table [dbo].[UsersLogs]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[UsersLogs-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[UsersLogs-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[UsersLogs-Insert-Update]
	/*@RowNumber int =Null OUTPUT , 
	@ID uniqueidentifier =Null  , 
	@User_ID uniqueidentifier =Null  , 
	@Date datetime =Null  , 
	@Table_ID uniqueidentifier =Null  , 
	@Event_ID uniqueidentifier =Null  , 
	@Item_ID uniqueidentifier =Null  , 
	@UsersLog_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[UsersLogs] 
					/*WHERE ([ID] = @ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[UsersLogs](/*[ID], [User_ID], [Date], [Table_ID], [Event_ID], [Item_ID]*/)
		VALUES     (/*@ID, @User_ID, @Date, @Table_ID, @Event_ID, @Item_ID*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [UsersLog_TimeStamp]
		FROM [dbo].[UsersLogs]
    	WHERE ([ID] = @ID)

		IF  @OldTimeStamp = @UsersLog_TimeStamp
		BEGIN*/
			Update [dbo].[UsersLogs] SET 
			/*[ID] =@ID, 
			[User_ID] =@User_ID, 
			[Date] =@Date, 
			[Table_ID] =@Table_ID, 
			[Event_ID] =@Event_ID, 
			[Item_ID] =@Item_ID*/
			/*WHERE ([ID] = @ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @RowNumber = [RowNumber], @UsersLog_TimeStamp = [UsersLog_TimeStamp]
    FROM [dbo].[UsersLogs]
	WHERE ([ID] = @ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[UsersLogs-Delete]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	delete records from table [dbo].[UsersLogs] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[UsersLogs-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[UsersLogs-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[UsersLogs-Delete]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@User_ID uniqueidentifier =null  , 
	@Date datetime =null  , 
	@Table_ID uniqueidentifier =null  , 
	@Event_ID uniqueidentifier =null  , 
	@Item_ID uniqueidentifier =null  , 
	@UsersLog_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[UsersLogs]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [User_ID] = ISNULL(@User_ID, [User_ID]) )
	AND ( [Date] = ISNULL(@Date, [Date]) )
	AND ( [Table_ID] = ISNULL(@Table_ID, [Table_ID]) )
	AND ( [Event_ID] = ISNULL(@Event_ID, [Event_ID]) )
	AND ( [Item_ID] = ISNULL(@Item_ID, [Item_ID]) )
	AND ( [UsersLog_TimeStamp] = ISNULL(@UsersLog_TimeStamp, [UsersLog_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[UsersLogs-Select]    Script Date: [[20120914065002]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065002]]
-- Description:	select records from table [dbo].[UsersLogs] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[UsersLogs-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[UsersLogs-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[UsersLogs-Select]
	/*@RowNumber int =null  , 
	@ID uniqueidentifier =null  , 
	@User_ID uniqueidentifier =null  , 
	@Date datetime =null  , 
	@Table_ID uniqueidentifier =null  , 
	@Event_ID uniqueidentifier =null  , 
	@Item_ID uniqueidentifier =null  , 
	@UsersLog_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[UsersLogs]
	WHERE /*( [RowNumber] = ISNULL(@RowNumber, [RowNumber]) )
	AND ( [ID] = ISNULL(@ID, [ID]) )
	AND ( [User_ID] = ISNULL(@User_ID, [User_ID]) )
	AND ( [Date] = ISNULL(@Date, [Date]) )
	AND ( [Table_ID] = ISNULL(@Table_ID, [Table_ID]) )
	AND ( [Event_ID] = ISNULL(@Event_ID, [Event_ID]) )
	AND ( [Item_ID] = ISNULL(@Item_ID, [Item_ID]) )
	AND ( [UsersLog_TimeStamp] = ISNULL(@UsersLog_TimeStamp, [UsersLog_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Workers-Insert]    Script Date: [[20120914065003]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065003]]
-- Description:	Insert record into table [dbo].[Workers]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Workers-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Workers-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Workers-Insert]
	/*@Worker_RowNumber int =Null OUTPUT , 
	@Worker_ID uniqueidentifier =Null  , 
	@Worker_Code varchar(50) =Null  , 
	@Worker_NameAr varchar(300) =Null  , 
	@Worker_NameEn varchar(300) =Null  , 
	@Worker_ResidenceDate datetime =Null  , 
	@Worker_ResidenceNumber decimal(20,0)  =Null  , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@HaveFamily tinyint =0  , 
	@Job_ID uniqueidentifier =Null  , 
	@HaveExternalGuaranty tinyint =0  , 
	@Worker_Notes varchar(max) =Null  , 
	@Worker_Search varchar(max) =Null  , 
	@Worker_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[Workers](/*[Worker_ID], [Worker_Code], [Worker_NameAr], [Worker_NameEn], [Worker_ResidenceDate], [Worker_ResidenceNumber], [MaritalStatus_ID], [HaveFamily], [Job_ID], [HaveExternalGuaranty], [Worker_Notes], [Worker_Search]*/)
	VALUES     (/*@Worker_ID, @Worker_Code, @Worker_NameAr, @Worker_NameEn, @Worker_ResidenceDate, @Worker_ResidenceNumber, @MaritalStatus_ID, @HaveFamily, @Job_ID, @HaveExternalGuaranty, @Worker_Notes, @Worker_Search*/)

	/*SELECT @Worker_RowNumber = [Worker_RowNumber], @Worker_TimeStamp = [Worker_TimeStamp]
    FROM [dbo].[Workers]
    WHERE  ( [Worker_ID] =@Worker_ID )
	AND  ( [Worker_Code] =@Worker_Code )
	AND  ( [Worker_NameAr] =@Worker_NameAr )
	AND  ( [Worker_NameEn] =@Worker_NameEn )
	AND  ( [Worker_ResidenceDate] =@Worker_ResidenceDate )
	AND  ( [Worker_ResidenceNumber] =@Worker_ResidenceNumber )
	AND  ( [MaritalStatus_ID] =@MaritalStatus_ID )
	AND  ( [HaveFamily] =@HaveFamily )
	AND  ( [Job_ID] =@Job_ID )
	AND  ( [HaveExternalGuaranty] =@HaveExternalGuaranty )
	AND  ( [Worker_Notes] =@Worker_Notes )
	AND  ( [Worker_Search] =@Worker_Search )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Workers-update]    Script Date: [[20120914065003]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065003]]
-- Description:	Update record in table [dbo].[Workers]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Workers-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Workers-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Workers-update]
	/*@Worker_RowNumber int =Null OUTPUT , 
	@Worker_ID uniqueidentifier =Null  , 
	@Worker_Code varchar(50) =Null  , 
	@Worker_NameAr varchar(300) =Null  , 
	@Worker_NameEn varchar(300) =Null  , 
	@Worker_ResidenceDate datetime =Null  , 
	@Worker_ResidenceNumber decimal(20,0)  =Null  , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@HaveFamily tinyint =0  , 
	@Job_ID uniqueidentifier =Null  , 
	@HaveExternalGuaranty tinyint =0  , 
	@Worker_Notes varchar(max) =Null  , 
	@Worker_Search varchar(max) =Null  , 
	@Worker_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [Worker_TimeStamp]
    FROM [dbo].[Workers]
    	WHERE ([Worker_ID] = @Worker_ID)

    IF  @OldTimeStamp = @Worker_TimeStamp
    BEGIN*/
		Update [dbo].[Workers] SET 
		/*[Worker_ID] =@Worker_ID, 
		[Worker_Code] =@Worker_Code, 
		[Worker_NameAr] =@Worker_NameAr, 
		[Worker_NameEn] =@Worker_NameEn, 
		[Worker_ResidenceDate] =@Worker_ResidenceDate, 
		[Worker_ResidenceNumber] =@Worker_ResidenceNumber, 
		[MaritalStatus_ID] =@MaritalStatus_ID, 
		[HaveFamily] =@HaveFamily, 
		[Job_ID] =@Job_ID, 
		[HaveExternalGuaranty] =@HaveExternalGuaranty, 
		[Worker_Notes] =@Worker_Notes, 
		[Worker_Search] =@Worker_Search*/
		/*WHERE ([Worker_ID] = @Worker_ID)*/
	/*END*/

	/*SELECT @Worker_RowNumber = [Worker_RowNumber], @Worker_TimeStamp = [Worker_TimeStamp]
    FROM [dbo].[Workers]
	WHERE ([Worker_ID] = @Worker_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Workers-Insert-Update]    Script Date: [[20120914065003]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065003]]
-- Description:	Insert OR Update record into table [dbo].[Workers]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Workers-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Workers-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Workers-Insert-Update]
	/*@Worker_RowNumber int =Null OUTPUT , 
	@Worker_ID uniqueidentifier =Null  , 
	@Worker_Code varchar(50) =Null  , 
	@Worker_NameAr varchar(300) =Null  , 
	@Worker_NameEn varchar(300) =Null  , 
	@Worker_ResidenceDate datetime =Null  , 
	@Worker_ResidenceNumber decimal(20,0)  =Null  , 
	@MaritalStatus_ID uniqueidentifier =Null  , 
	@HaveFamily tinyint =0  , 
	@Job_ID uniqueidentifier =Null  , 
	@HaveExternalGuaranty tinyint =0  , 
	@Worker_Notes varchar(max) =Null  , 
	@Worker_Search varchar(max) =Null  , 
	@Worker_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[Workers] 
					/*WHERE ([Worker_ID] = @Worker_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[Workers](/*[Worker_ID], [Worker_Code], [Worker_NameAr], [Worker_NameEn], [Worker_ResidenceDate], [Worker_ResidenceNumber], [MaritalStatus_ID], [HaveFamily], [Job_ID], [HaveExternalGuaranty], [Worker_Notes], [Worker_Search]*/)
		VALUES     (/*@Worker_ID, @Worker_Code, @Worker_NameAr, @Worker_NameEn, @Worker_ResidenceDate, @Worker_ResidenceNumber, @MaritalStatus_ID, @HaveFamily, @Job_ID, @HaveExternalGuaranty, @Worker_Notes, @Worker_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [Worker_TimeStamp]
		FROM [dbo].[Workers]
    	WHERE ([Worker_ID] = @Worker_ID)

		IF  @OldTimeStamp = @Worker_TimeStamp
		BEGIN*/
			Update [dbo].[Workers] SET 
			/*[Worker_ID] =@Worker_ID, 
			[Worker_Code] =@Worker_Code, 
			[Worker_NameAr] =@Worker_NameAr, 
			[Worker_NameEn] =@Worker_NameEn, 
			[Worker_ResidenceDate] =@Worker_ResidenceDate, 
			[Worker_ResidenceNumber] =@Worker_ResidenceNumber, 
			[MaritalStatus_ID] =@MaritalStatus_ID, 
			[HaveFamily] =@HaveFamily, 
			[Job_ID] =@Job_ID, 
			[HaveExternalGuaranty] =@HaveExternalGuaranty, 
			[Worker_Notes] =@Worker_Notes, 
			[Worker_Search] =@Worker_Search*/
			/*WHERE ([Worker_ID] = @Worker_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @Worker_RowNumber = [Worker_RowNumber], @Worker_TimeStamp = [Worker_TimeStamp]
    FROM [dbo].[Workers]
	WHERE ([Worker_ID] = @Worker_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Workers-Delete]    Script Date: [[20120914065003]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065003]]
-- Description:	delete records from table [dbo].[Workers] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Workers-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Workers-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Workers-Delete]
	/*@Worker_RowNumber int =null  , 
	@Worker_ID uniqueidentifier =null  , 
	@Worker_Code varchar(50) =null  , 
	@Worker_NameAr varchar(300) =null  , 
	@Worker_NameEn varchar(300) =null  , 
	@Worker_ResidenceDate datetime =null  , 
	@Worker_ResidenceNumber decimal(20,0)  =null  , 
	@MaritalStatus_ID uniqueidentifier =null  , 
	@HaveFamily tinyint =null  , 
	@Job_ID uniqueidentifier =null  , 
	@HaveExternalGuaranty tinyint =null  , 
	@Worker_Notes varchar(max) =null  , 
	@Worker_Search varchar(max) =null  , 
	@Worker_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[Workers]
	WHERE /*( [Worker_RowNumber] = ISNULL(@Worker_RowNumber, [Worker_RowNumber]) )
	AND ( [Worker_ID] = ISNULL(@Worker_ID, [Worker_ID]) )
	AND ( [Worker_Code] like ISNULL(@Worker_Code, [Worker_Code]) )
	AND ( [Worker_NameAr] like ISNULL(@Worker_NameAr, [Worker_NameAr]) )
	AND ( [Worker_NameEn] like ISNULL(@Worker_NameEn, [Worker_NameEn]) )
	AND ( [Worker_ResidenceDate] = ISNULL(@Worker_ResidenceDate, [Worker_ResidenceDate]) )
	AND ( [Worker_ResidenceNumber] = ISNULL(@Worker_ResidenceNumber, [Worker_ResidenceNumber]) )
	AND ( [MaritalStatus_ID] = ISNULL(@MaritalStatus_ID, [MaritalStatus_ID]) )
	AND ( [HaveFamily] = ISNULL(@HaveFamily, [HaveFamily]) )
	AND ( [Job_ID] = ISNULL(@Job_ID, [Job_ID]) )
	AND ( [HaveExternalGuaranty] = ISNULL(@HaveExternalGuaranty, [HaveExternalGuaranty]) )
	AND ( [Worker_Notes] like ISNULL(@Worker_Notes, [Worker_Notes]) )
	AND ( [Worker_Search] like ISNULL(@Worker_Search, [Worker_Search]) )
	AND ( [Worker_TimeStamp] = ISNULL(@Worker_TimeStamp, [Worker_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[Workers-Select]    Script Date: [[20120914065003]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065003]]
-- Description:	select records from table [dbo].[Workers] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[Workers-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[Workers-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[Workers-Select]
	/*@Worker_RowNumber int =null  , 
	@Worker_ID uniqueidentifier =null  , 
	@Worker_Code varchar(50) =null  , 
	@Worker_NameAr varchar(300) =null  , 
	@Worker_NameEn varchar(300) =null  , 
	@Worker_ResidenceDate datetime =null  , 
	@Worker_ResidenceNumber decimal(20,0)  =null  , 
	@MaritalStatus_ID uniqueidentifier =null  , 
	@HaveFamily tinyint =null  , 
	@Job_ID uniqueidentifier =null  , 
	@HaveExternalGuaranty tinyint =null  , 
	@Worker_Notes varchar(max) =null  , 
	@Worker_Search varchar(max) =null  , 
	@Worker_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[Workers]
	WHERE /*( [Worker_RowNumber] = ISNULL(@Worker_RowNumber, [Worker_RowNumber]) )
	AND ( [Worker_ID] = ISNULL(@Worker_ID, [Worker_ID]) )
	AND ( [Worker_Code] like ISNULL(@Worker_Code, [Worker_Code]) )
	AND ( [Worker_NameAr] like ISNULL(@Worker_NameAr, [Worker_NameAr]) )
	AND ( [Worker_NameEn] like ISNULL(@Worker_NameEn, [Worker_NameEn]) )
	AND ( [Worker_ResidenceDate] = ISNULL(@Worker_ResidenceDate, [Worker_ResidenceDate]) )
	AND ( [Worker_ResidenceNumber] = ISNULL(@Worker_ResidenceNumber, [Worker_ResidenceNumber]) )
	AND ( [MaritalStatus_ID] = ISNULL(@MaritalStatus_ID, [MaritalStatus_ID]) )
	AND ( [HaveFamily] = ISNULL(@HaveFamily, [HaveFamily]) )
	AND ( [Job_ID] = ISNULL(@Job_ID, [Job_ID]) )
	AND ( [HaveExternalGuaranty] = ISNULL(@HaveExternalGuaranty, [HaveExternalGuaranty]) )
	AND ( [Worker_Notes] like ISNULL(@Worker_Notes, [Worker_Notes]) )
	AND ( [Worker_Search] like ISNULL(@Worker_Search, [Worker_Search]) )
	AND ( [Worker_TimeStamp] = ISNULL(@Worker_TimeStamp, [Worker_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[WorkersAttachments-Insert]    Script Date: [[20120914065004]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065004]]
-- Description:	Insert record into table [dbo].[WorkersAttachments]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[WorkersAttachments-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[WorkersAttachments-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[WorkersAttachments-Insert]
	/*@WorkerAttachment_RowNumber int =Null OUTPUT , 
	@WorkerAttachment_ID uniqueidentifier =Null  , 
	@Worker_ID uniqueidentifier =Null  , 
	@File_DisplayName varchar(100) =Null  , 
	@File_Path varchar(max) =Null  , 
	@Is_Encrypted tinyint =0  , 
	@File_Bytes varbinary =Null  , 
	@File_Notes varchar(max) =Null  , 
	@File_Search varchar(max) =Null  , 
	@Mime_ID uniqueidentifier =Null  , 
	@WorkerAttachment_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[WorkersAttachments](/*[WorkerAttachment_ID], [Worker_ID], [File_DisplayName], [File_Path], [Is_Encrypted], [File_Bytes], [File_Notes], [File_Search], [Mime_ID]*/)
	VALUES     (/*@WorkerAttachment_ID, @Worker_ID, @File_DisplayName, @File_Path, @Is_Encrypted, @File_Bytes, @File_Notes, @File_Search, @Mime_ID*/)

	/*SELECT @WorkerAttachment_RowNumber = [WorkerAttachment_RowNumber], @WorkerAttachment_TimeStamp = [WorkerAttachment_TimeStamp]
    FROM [dbo].[WorkersAttachments]
    WHERE  ( [WorkerAttachment_ID] =@WorkerAttachment_ID )
	AND  ( [Worker_ID] =@Worker_ID )
	AND  ( [File_DisplayName] =@File_DisplayName )
	AND  ( [File_Path] =@File_Path )
	AND  ( [Is_Encrypted] =@Is_Encrypted )
	AND  ( [File_Bytes] =@File_Bytes )
	AND  ( [File_Notes] =@File_Notes )
	AND  ( [File_Search] =@File_Search )
	AND  ( [Mime_ID] =@Mime_ID )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[WorkersAttachments-update]    Script Date: [[20120914065004]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065004]]
-- Description:	Update record in table [dbo].[WorkersAttachments]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[WorkersAttachments-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[WorkersAttachments-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[WorkersAttachments-update]
	/*@WorkerAttachment_RowNumber int =Null OUTPUT , 
	@WorkerAttachment_ID uniqueidentifier =Null  , 
	@Worker_ID uniqueidentifier =Null  , 
	@File_DisplayName varchar(100) =Null  , 
	@File_Path varchar(max) =Null  , 
	@Is_Encrypted tinyint =0  , 
	@File_Bytes varbinary =Null  , 
	@File_Notes varchar(max) =Null  , 
	@File_Search varchar(max) =Null  , 
	@Mime_ID uniqueidentifier =Null  , 
	@WorkerAttachment_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [WorkerAttachment_TimeStamp]
    FROM [dbo].[WorkersAttachments]
    	WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)

    IF  @OldTimeStamp = @WorkerAttachment_TimeStamp
    BEGIN*/
		Update [dbo].[WorkersAttachments] SET 
		/*[WorkerAttachment_ID] =@WorkerAttachment_ID, 
		[Worker_ID] =@Worker_ID, 
		[File_DisplayName] =@File_DisplayName, 
		[File_Path] =@File_Path, 
		[Is_Encrypted] =@Is_Encrypted, 
		[File_Bytes] =@File_Bytes, 
		[File_Notes] =@File_Notes, 
		[File_Search] =@File_Search, 
		[Mime_ID] =@Mime_ID*/
		/*WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)*/
	/*END*/

	/*SELECT @WorkerAttachment_RowNumber = [WorkerAttachment_RowNumber], @WorkerAttachment_TimeStamp = [WorkerAttachment_TimeStamp]
    FROM [dbo].[WorkersAttachments]
	WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[WorkersAttachments-Insert-Update]    Script Date: [[20120914065004]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065004]]
-- Description:	Insert OR Update record into table [dbo].[WorkersAttachments]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[WorkersAttachments-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[WorkersAttachments-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[WorkersAttachments-Insert-Update]
	/*@WorkerAttachment_RowNumber int =Null OUTPUT , 
	@WorkerAttachment_ID uniqueidentifier =Null  , 
	@Worker_ID uniqueidentifier =Null  , 
	@File_DisplayName varchar(100) =Null  , 
	@File_Path varchar(max) =Null  , 
	@Is_Encrypted tinyint =0  , 
	@File_Bytes varbinary =Null  , 
	@File_Notes varchar(max) =Null  , 
	@File_Search varchar(max) =Null  , 
	@Mime_ID uniqueidentifier =Null  , 
	@WorkerAttachment_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[WorkersAttachments] 
					/*WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[WorkersAttachments](/*[WorkerAttachment_ID], [Worker_ID], [File_DisplayName], [File_Path], [Is_Encrypted], [File_Bytes], [File_Notes], [File_Search], [Mime_ID]*/)
		VALUES     (/*@WorkerAttachment_ID, @Worker_ID, @File_DisplayName, @File_Path, @Is_Encrypted, @File_Bytes, @File_Notes, @File_Search, @Mime_ID*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [WorkerAttachment_TimeStamp]
		FROM [dbo].[WorkersAttachments]
    	WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)

		IF  @OldTimeStamp = @WorkerAttachment_TimeStamp
		BEGIN*/
			Update [dbo].[WorkersAttachments] SET 
			/*[WorkerAttachment_ID] =@WorkerAttachment_ID, 
			[Worker_ID] =@Worker_ID, 
			[File_DisplayName] =@File_DisplayName, 
			[File_Path] =@File_Path, 
			[Is_Encrypted] =@Is_Encrypted, 
			[File_Bytes] =@File_Bytes, 
			[File_Notes] =@File_Notes, 
			[File_Search] =@File_Search, 
			[Mime_ID] =@Mime_ID*/
			/*WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @WorkerAttachment_RowNumber = [WorkerAttachment_RowNumber], @WorkerAttachment_TimeStamp = [WorkerAttachment_TimeStamp]
    FROM [dbo].[WorkersAttachments]
	WHERE ([WorkerAttachment_ID] = @WorkerAttachment_ID)*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[WorkersAttachments-Delete]    Script Date: [[20120914065004]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065004]]
-- Description:	delete records from table [dbo].[WorkersAttachments] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[WorkersAttachments-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[WorkersAttachments-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[WorkersAttachments-Delete]
	/*@WorkerAttachment_RowNumber int =null  , 
	@WorkerAttachment_ID uniqueidentifier =null  , 
	@Worker_ID uniqueidentifier =null  , 
	@File_DisplayName varchar(100) =null  , 
	@File_Path varchar(max) =null  , 
	@Is_Encrypted tinyint =null  , 
	@File_Bytes varbinary =null  , 
	@File_Notes varchar(max) =null  , 
	@File_Search varchar(max) =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@WorkerAttachment_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[WorkersAttachments]
	WHERE /*( [WorkerAttachment_RowNumber] = ISNULL(@WorkerAttachment_RowNumber, [WorkerAttachment_RowNumber]) )
	AND ( [WorkerAttachment_ID] = ISNULL(@WorkerAttachment_ID, [WorkerAttachment_ID]) )
	AND ( [Worker_ID] = ISNULL(@Worker_ID, [Worker_ID]) )
	AND ( [File_DisplayName] like ISNULL(@File_DisplayName, [File_DisplayName]) )
	AND ( [File_Path] like ISNULL(@File_Path, [File_Path]) )
	AND ( [Is_Encrypted] = ISNULL(@Is_Encrypted, [Is_Encrypted]) )
	AND ( [File_Bytes] = ISNULL(@File_Bytes, [File_Bytes]) )
	AND ( [File_Notes] like ISNULL(@File_Notes, [File_Notes]) )
	AND ( [File_Search] like ISNULL(@File_Search, [File_Search]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [WorkerAttachment_TimeStamp] = ISNULL(@WorkerAttachment_TimeStamp, [WorkerAttachment_TimeStamp]) )*/
END
GO
-- =============================================



--USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[WorkersAttachments-Select]    Script Date: [[20120914065004]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914065004]]
-- Description:	select records from table [dbo].[WorkersAttachments] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[WorkersAttachments-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[WorkersAttachments-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[WorkersAttachments-Select]
	/*@WorkerAttachment_RowNumber int =null  , 
	@WorkerAttachment_ID uniqueidentifier =null  , 
	@Worker_ID uniqueidentifier =null  , 
	@File_DisplayName varchar(100) =null  , 
	@File_Path varchar(max) =null  , 
	@Is_Encrypted tinyint =null  , 
	@File_Bytes varbinary =null  , 
	@File_Notes varchar(max) =null  , 
	@File_Search varchar(max) =null  , 
	@Mime_ID uniqueidentifier =null  , 
	@WorkerAttachment_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[WorkersAttachments]
	WHERE /*( [WorkerAttachment_RowNumber] = ISNULL(@WorkerAttachment_RowNumber, [WorkerAttachment_RowNumber]) )
	AND ( [WorkerAttachment_ID] = ISNULL(@WorkerAttachment_ID, [WorkerAttachment_ID]) )
	AND ( [Worker_ID] = ISNULL(@Worker_ID, [Worker_ID]) )
	AND ( [File_DisplayName] like ISNULL(@File_DisplayName, [File_DisplayName]) )
	AND ( [File_Path] like ISNULL(@File_Path, [File_Path]) )
	AND ( [Is_Encrypted] = ISNULL(@Is_Encrypted, [Is_Encrypted]) )
	AND ( [File_Bytes] = ISNULL(@File_Bytes, [File_Bytes]) )
	AND ( [File_Notes] like ISNULL(@File_Notes, [File_Notes]) )
	AND ( [File_Search] like ISNULL(@File_Search, [File_Search]) )
	AND ( [Mime_ID] = ISNULL(@Mime_ID, [Mime_ID]) )
	AND ( [WorkerAttachment_TimeStamp] = ISNULL(@WorkerAttachment_TimeStamp, [WorkerAttachment_TimeStamp]) )*/
END
GO
-- =============================================
